Integration Pattern
- Receive a user request.
- Create or reuse an agent runtime.
- Execute LLM-generated code or terminal commands.
- Read outputs and files.
- Return results to the user.
- Clean up runtime resources.
Example
Best Practices
- Store API keys in environment variables, never in code.
- Always clean up runtimes in
finallyblocks. - Use code contexts to persist state across multiple
run_codecalls. - Use
run_cmdfor package installs and shell operations. - Set appropriate timeouts for long-running workloads.
Code Execution
Run Python and JavaScript in isolated runtimes
Command Execution
Run shell commands and CLI tooling

