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

input

Error message

input

What it means

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

Source

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

    attributes: dict[str, Any] = field(default_factory=dict)
    children: list["Span"] = field(default_factory=list)


@dataclass
class Runner:
    input_guardrails: list[InputGuardrail] = field(default_factory=list)
    output_guardrails: list[OutputGuardrail] = field(default_factory=list)
    max_hops: int = 3
    trace: Span = field(default_factory=lambda: Span(name="run"))

    def run(self, agent: Agent, user_input: str) -> str:
        for guard in self.input_guardrails:
            ok, reason = guard.check(user_input)
            span = Span(name=f"input_guardrail.{guard.name}",
                        attributes={"passed": ok, "reason": reason})
            self.trace.children.append(span)
            if not ok:
                raise GuardrailTripped("input", reason)

        current_agent = agent
        current_input = user_input
        final_output = ""
        for hop in range(self.max_hops):
            agent_span = Span(name=f"agent.{current_agent.name}",
                              attributes={"hop": hop,
                                          "instructions": current_agent.instructions[:40]})
            self.trace.children.append(agent_span)

            policy_output = current_agent.policy(current_input)
            kind = policy_output["kind"]

            if kind == "final":
                final_output = policy_output["text"]
                agent_span.children.append(
                    Span(name="llm_generation",
                         attributes={"output": final_output[:60]})

View on GitHub (pinned to 39ea8a1c6d)

When it happens

Trigger: Thrown at phases/14-agent-engineering/16-openai-agents-sdk/code/main.py:79 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/570c3308bd61aaf8. Report an issue: GitHub.