Skip to main content

What You’ll Learn

  • Defining a @function_tool with the agents package that executes Python in a Declaw sandbox
  • Creating an Agent with instructions and tools
  • Running the agent with Runner.run() and reading result.final_output
  • Demo mode that exercises the sandbox tool directly without needing an OpenAI key

Prerequisites

  • Declaw instance running and DECLAW_API_KEY / DECLAW_DOMAIN set
  • 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:

2. Create an agent and run it

3. Demo mode (no API key needed)

Run the sandbox tool directly to verify it works before connecting the agent:

Expected Output

In demo mode: