Problem and boundaries
The support team needs to classify new tickets as product, billing, or security issues and assign a priority. The system must not change customer data automatically; insufficient evidence must result in a human handoff.
Design
The agent can call only two read-only tools: lookup_ticket and search_policy. The server validates the ticket id, role, and tool-call budget. The final result is written to a review queue and never sends an external message directly.
Minimal implementation
from dataclasses import dataclass
@dataclass(frozen=True)
class Triage:
category: str
priority: str
needs_human: bool
def accept(result: dict) -> Triage:
allowed = {'product', 'billing', 'security'}
if result.get('category') not in allowed:
raise ValueError('unknown category')
return Triage(result['category'], result.get('priority', 'normal'), bool(result.get('needs_human', True)))
Reproduction steps
- Prepare redacted ticket samples and policy excerpts, with the expected category and cases that must go to a person.
- Implement read-only tools and assign an idempotent run_id to each run.
- Validate the structured result before writing it to the review queue.
- Assert from the trace that no write tool was called, and sample the referenced policy ids.
Verification checklist
Check empty tickets, unknown categories, tool timeouts, duplicate run_id values, and human handoff for security tickets. Record events without retaining the complete customer body.
Common questions
Can the agent close a ticket automatically? No. Closing is a side effect and needs separate authorization and human confirmation.
How can a failed run be replayed? Read the event summary by run_id and replay it in an isolated environment.
Official references
OpenAI Agents guide; OpenAI Structured Outputs.
Last checked: 2026-11-16. Follow the linked sources for current interfaces and security boundaries; this case makes no performance or cost claim.
