What You’ll Learn
- Defining a
@function_toolwith theagentspackage that executes Python in a Declaw sandbox - Creating an
Agentwith instructions and tools - Running the agent with
Runner.run()and readingresult.final_output - Demo mode that exercises the sandbox tool directly 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. Define the Declaw sandbox tool
The@function_tool decorator from the agents package generates a tool schema from the function signature and docstring: