Back to Prompt Library
implementation
Implement Tool Use for Code Execution and Testing
Inspect the original prompt language first, then copy or adapt it once you know how it fits your workflow.
Linked challenge: Self-Improving GPT-5.3-Codex Agent for Code Generation & Refinement
Format
Text-first
Lines
1
Sections
1
Linked challenge
Self-Improving GPT-5.3-Codex Agent for Code Generation & Refinement
Prompt source
Original prompt text with formatting preserved for inspection.
1 lines
1 sections
No variables
0 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.
Adaptation plan
Keep the source stable, then change the prompt in a predictable order so the next run is easier to evaluate.
Keep stable
Hold the task contract and output shape stable so generated implementations remain comparable.
Tune next
Update libraries, interfaces, and environment assumptions to match the stack you actually run.
Verify after
Test failure handling, edge cases, and any code paths that depend on hidden context or secrets.