Overview
Observe the run. Keep the Agents SDK in control.
The lab uses one OpenAI agent and one real local function tool. The OpenAI Agents SDK owns model routing, tool execution, output, and exceptions. Platform receives a separate, one-way record of completed runtime boundaries.
You will learn
How public Agents SDK lifecycle hooks map an agent, model calls, and a real tool call to runtime evidence.
You will build
One correlated execution for one Runner invocation, with no custom SDK internals or tracing interception.
Architecture
A small agent with one actual tool call.
Execution plane
OpenAI Agents SDK
Runs the agent, model turns, and local function tool.
Evidence plane
BHANUJ Agents Runtime
Records ordered lifecycle evidence only.
The first model turn is publicly configured with named tool_choice="lookup_policy". The SDK resets that choice after the local tool runs, then performs its normal final model turn.
Prerequisites
What you need.
- Python 3.12 or later and pip.
- An OpenAI API key and an available model.
- The BHANUJ OSS repository only when you want to send runtime evidence.
Run locally
Run the agent without BHANUJ OSS first.
The lab pins openai-agents==0.22.2. It needs an OpenAI API key, but no database, cloud infrastructure, or Detailed Tool Calls platform connection.
git clone https://github.com/Bhanuj-AI/labs.git
cd labs/agent-frameworks/openai/openai-agents-tool-intg
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
export OPENAI_API_KEY=...
export OPENAI_MODEL=gpt-5-minipython app.pyAgent result: Policy POL-100: ACTIVE.Enable evidence
Connect the unchanged run to BHANUJ OSS.
Start BHANUJ OSS in development mode, then set the three runtime-scope variables and run the same app. The OpenAI application remains independently owned by the SDK.
cd /path/to/ai-governance-oss
AI_GOVERNANCE_AUTH_MODE=development \
uv run uvicorn ai_governance.api.app:app --reloadexport AI_GOVERNANCE_BASE_URL=http://localhost:8000
export AI_GOVERNANCE_ORGANIZATION_ID=org_default
export AI_GOVERNANCE_PROJECT_ID=project_default
python app.pyAgent result: Policy POL-100: ACTIVE.
BHANUJ execution ID: <execution-id>
BHANUJ evidence status: SUCCEEDEDInspect the execution
One execution ID connects the full run.
The CLI prints the execution ID after the start request succeeds. Find that exact ID in Agents Runtime to inspect the ordered evidence below.
- 1Policy Validation Agent · Step StartedWORKFLOW_STEP
- 2gpt-5-mini · Model Completed · 1MODEL_CALL
- 3lookup_policy · Tool CompletedTOOL_CALL
- 4gpt-5-mini · Model Completed · 2MODEL_CALL
- 5Policy Validation Agent · Step CompletedWORKFLOW_STEP
The execution also contains the platform-generated EXECUTION_STARTED and successful completion records. No prompt text, tool arguments, tool output, model output, reasoning, or raw SDK payload is sent.
OpenAI Agents SDK references
Ready to run it?
Fork the lab, run the real agent and local tool, then enable runtime evidence when BHANUJ OSS is available.
