{"record":{"id":"7947ef90e82786f8","repo":"rohitg00/ai-engineering-from-scratch","slug":"output","errorCode":null,"errorMessage":"output","messagePattern":"output","errorType":"exception","errorClass":"GuardrailTripped","httpStatus":null,"severity":"error","filePath":"phases/14-agent-engineering/16-openai-agents-sdk/code/main.py","lineNumber":144,"sourceCode":"                    break\n                agent_span.children.append(\n                    Span(name=f\"handoff.{handoff.tool_name}\",\n                         attributes={\"from\": current_agent.name,\n                                     \"to\": target_name})\n                )\n                current_agent = handoff.target\n                current_input = policy_output.get(\"input\", current_input)\n                continue\n            final_output = f\"error: unknown policy kind {kind}\"\n            break\n\n        for guard in self.output_guardrails:\n            ok, reason = guard.check(final_output)\n            span = Span(name=f\"output_guardrail.{guard.name}\",\n                        attributes={\"passed\": ok, \"reason\": reason})\n            self.trace.children.append(span)\n            if not ok:\n                raise GuardrailTripped(\"output\", reason)\n\n        return final_output\n\n\ndef _print_span(span: Span, indent: int = 0) -> None:\n    prefix = \"  \" * indent\n    attrs = \" \".join(f\"{k}={v!r}\" for k, v in span.attributes.items())\n    print(f\"{prefix}{span.name}  {attrs}\")\n    for child in span.children:\n        _print_span(child, indent + 1)\n\n\ndef _triage_policy(user_input: str) -> dict[str, Any]:\n    t = user_input.lower()\n    if \"refund\" in t or \"billing\" in t or \"invoice\" in t:\n        return {\"kind\": \"handoff\", \"to\": \"billing\", \"input\": user_input}\n    if \"error\" in t or \"crash\" in t or \"bug\" in t:\n        return {\"kind\": \"handoff\", \"to\": \"support\", \"input\": user_input}","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/14-agent-engineering/16-openai-agents-sdk/code/main.py#L126-L162","documentation":"Error \"output\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/14-agent-engineering/16-openai-agents-sdk/code/main.py:144 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}