An OpenAI Agent is a specialist contract: name, instructions, model choice, tools, handoffs, guardrails, MCP connections, and optional structured output. Put stable job rules on the agent, pass trusted application dependencies through local run context, and require a typed output whenever downstream code needs fields rather than prose.
You will define a typed triage agent, use local context without exposing it to the model, and decide when model selection belongs in configuration.
Conversation input is visible to the model. Local run context is visible to your callbacks and tools. It can hold authenticated identity, repositories, loggers, or feature flags—but those values reach the model only if your code deliberately renders or returns them.
typed_agent.py:
The generic type documents which context tools/callbacks may receive. output_type asks the SDK/model path for schema-conforming output. Your code must still apply business validation.
Select a model using current official guidance and an evaluation suite, not reputation. Compare task quality, tool-call accuracy, latency, availability, and cost for your workload. Keep the chosen identifier in deployable configuration and record it on each run.
Use a cheaper/faster model only after it meets the required scorecard. Use a stronger model only when its gain justifies operational cost. Do not let a book chapter become your source of truth for current model names.
Failure injection: Change the prompt to request an extra internal_reasoning field. The schema should prevent the application from depending on undeclared model output.
Version instructions and schemas, keep model selection behind tested configuration, use dynamic instructions only for truly request-dependent guidance, and attach prompt/model/schema versions to trace and outcome records.
Add a model-routing configuration with two candidates. Write an offline evaluation that selects the cheapest candidate meeting minimum quality, safety, and latency thresholds.