What You’ll Learn
- Implementing the
CodeExecutorABC fromautogen_core.code_executorbacked by Declaw sandboxes - Supporting both Python and shell code blocks
- Integrating with
CodeExecutorAgentandAssistantAgent - Running a
RoundRobinGroupChatteam with termination conditions - Demo mode that exercises the executor without needing an OpenAI key
Prerequisites
- Declaw instance running and
DECLAW_API_KEY/DECLAW_DOMAINset OPENAI_API_KEY(optional — the example runs in demo mode without it)
This example is available in Python. TypeScript support coming soon.
Code Walkthrough
1. Implement DecawCodeExecutor
Subclass CodeExecutor and implement execute_code_blocks. The method receives a list of CodeBlock objects — each has a language and code field:
execute_code_blocks call, ensuring full isolation between turns.