rohitg00/ai-engineering-from-scratch · error · GuardrailTripped

output

Error message

output

What it means

Error "output" thrown in rohitg00/ai-engineering-from-scratch.

Source

Thrown at phases/14-agent-engineering/16-openai-agents-sdk/code/main.py:144

                    break
                agent_span.children.append(
                    Span(name=f"handoff.{handoff.tool_name}",
                         attributes={"from": current_agent.name,
                                     "to": target_name})
                )
                current_agent = handoff.target
                current_input = policy_output.get("input", current_input)
                continue
            final_output = f"error: unknown policy kind {kind}"
            break

        for guard in self.output_guardrails:
            ok, reason = guard.check(final_output)
            span = Span(name=f"output_guardrail.{guard.name}",
                        attributes={"passed": ok, "reason": reason})
            self.trace.children.append(span)
            if not ok:
                raise GuardrailTripped("output", reason)

        return final_output


def _print_span(span: Span, indent: int = 0) -> None:
    prefix = "  " * indent
    attrs = " ".join(f"{k}={v!r}" for k, v in span.attributes.items())
    print(f"{prefix}{span.name}  {attrs}")
    for child in span.children:
        _print_span(child, indent + 1)


def _triage_policy(user_input: str) -> dict[str, Any]:
    t = user_input.lower()
    if "refund" in t or "billing" in t or "invoice" in t:
        return {"kind": "handoff", "to": "billing", "input": user_input}
    if "error" in t or "crash" in t or "bug" in t:
        return {"kind": "handoff", "to": "support", "input": user_input}

View on GitHub (pinned to 39ea8a1c6d)

When it happens

Trigger: Thrown at phases/14-agent-engineering/16-openai-agents-sdk/code/main.py:144 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26). Data as JSON: /api/errors/7947ef90e82786f8. Report an issue: GitHub.