ADK for TypeScript: API Reference
    Preparing search index...

    Function requireAgent

    • The agent driving ctx, for code that only runs because one is.

      An LLM flow, an agent transfer, a tool call: each is reached from inside an agent's own execution, so InvocationContext.agent is set by construction. Going through here says that out loud, and turns a violated assumption into a named error rather than a property access on undefined several frames away.

      A free function rather than an accessor on the class, because a good deal of code (and most tests) passes a duck-typed context object; a getter would be simply absent on those, which fails less clearly than not having the agent.

      Parameters

      Returns BaseAgent

      if the invocation is driving a bare node rather than an agent.