Back to prompt library
Implement Tool Use for Code Execution and Testing
Linked challenge: Self-Improving GPT-5.3-Codex Agent for Code Generation & Refinement
Prompt source
implementation1 lines1 sectionsNo variables0 checklist items
Create a custom tool for your OpenAI agent that can execute Python code in a sandboxed environment and return the results, including standard output and any errors. This tool should also be capable of running a set of predefined unit tests against the generated code. Show how to integrate this tool into your OpenAI Agents SDK agent using the `tool_resources` and `function_calling` features. Provide a Python snippet demonstrating the tool definition and how the agent would invoke it.