GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • ADK for TypeScript: API Reference

This view

  • Original page
  • New address

GeezerVison is showing adk.dev — InvocationContext | ADK for TypeScript: API Reference - v2.5.0

  • InvocationContext

Class InvocationContext

An invocation context represents the data of a single invocation of an agent.

An invocation: 1. Starts with a user message and ends with a final response. 2. Can contain one or multiple agent calls. 3. Is handled by runner.runAsync().

An invocation runs an agent until it does not request to transfer to another agent.

An agent call: 1. Is handled by agent.runAsync(). 2. Ends when agent.runAsync() ends.

An LLM agent call is an agent with a BaseLLMFlow. An LLM agent call can contain one or multiple steps.

An LLM agent runs steps in a loop until:

  1. A final response is generated.
  2. The agent transfers to another agent.
  3. endInvocation is set to true by any callbacks or tools.

A step:

  1. Calls the LLM only once and yields its response.
  2. Calls the tools and yields their responses if requested.

The summarization of the function response is considered another step, since it is another llm call. A step ends when it's done calling llm and tools, or if endInvocation is set to true at any time.

   ┌─────────────────────── invocation ──────────────────────────┐
┌──────────── llm_agent_call_1 ────────────┐ ┌─ agent_call_2 ─┐
┌──── step_1 ────────┐ ┌───── step_2 ──────┐
[call_llm] [call_tool] [call_llm] [transfer]
  • Defined in core/src/agents/invocation_context.ts:176

Constructors

constructor

  • new InvocationContext(params: InvocationContextParams): InvocationContext

    Parameters

    • params: InvocationContextParams

      The parameters for creating an invocation context.

    Returns InvocationContext

    • Defined in core/src/agents/invocation_context.ts:310

Properties

Optional Readonlya2aMetadata

a2aMetadata?: Record<string, unknown>

Request-level metadata passed from an incoming A2A request or caller.

  • Defined in core/src/agents/invocation_context.ts:305

Optional ReadonlyabortSignal

abortSignal?: AbortSignal
  • Defined in core/src/agents/invocation_context.ts:259

OptionalactiveStreamingTools

activeStreamingTools?: Record<string, ActiveStreamingTool>

The running streaming tools of this invocation.

  • Defined in core/src/agents/invocation_context.ts:252

Optionalagent

agent?: BaseAgent<BaseAgentConfig>

The agent driving this invocation.

Unset when the root being run is a bare BaseNode — a Workflow handed straight to the Runner — because there is no agent in play at that level. Nodes deeper in the graph that are agents get their own contexts with this set. Mirrors adk-python, whose field is BaseAgent | BaseNode | None and which passes None on the node path.

Most code reaches this from inside an agent's own execution, where it is always set; prefer requireAgent there, so a broken invariant fails by name rather than as a property access on undefined.

  • Defined in core/src/agents/invocation_context.ts:211

Optional ReadonlyartifactService

artifactService?: SessionArtifactService
  • Defined in core/src/agents/invocation_context.ts:177

Optionalbranch

branch?: string

The branch of the invocation context.

The format is like agent_1.agent_2.agent_3, where agent_1 is the parent of agent_2, and agent_2 is the parent of agent_3.

Branch is used when multiple sub-agents shouldn't see their peer agents' conversation history.

  • Defined in core/src/agents/invocation_context.ts:196

Optional ReadonlycredentialService

credentialService?: BaseCredentialService
  • Defined in core/src/agents/invocation_context.ts:180

endInvocation

endInvocation: boolean

Whether to end this invocation. Set to true in callbacks or tools to terminate this invocation.

  • Defined in core/src/agents/invocation_context.ts:227

OptionaleventQueue

eventQueue?: AsyncQueue<Event>

An optional channel into which a running tool can push events to be interleaved into the agent's output stream. Set by the LLM flow around tool execution so a NodeTool (running a node/workflow) can surface the node's intermediate and interrupt events. Cleared once tools finish.

  • Defined in core/src/agents/invocation_context.ts:267

ReadonlyinvocationId

invocationId: string

The id of this invocation context.

  • Defined in core/src/agents/invocation_context.ts:185

OptionalisolationScope

isolationScope?: string

Workflow: the isolation scope of the node this context runs in. Events carrying a different scope are withheld from this agent's LLM request.

  • Defined in core/src/agents/invocation_context.ts:280

OptionalliveRequestQueue

liveRequestQueue?: LiveRequestQueue

The live request queue feeding the model on the bidirectional (live) path. Set only for invocations started via runner.runLive.

  • Defined in core/src/agents/invocation_context.ts:293

OptionalliveSessionResumptionHandle

liveSessionResumptionHandle?: string

The most recent session resumption handle observed on the live path. Updated as the server emits resumption updates so a reconnect can restore server-side state instead of replaying history. Mutable by design.

  • Defined in core/src/agents/invocation_context.ts:300

Optional ReadonlymemoryService

memoryService?: BaseMemoryService
  • Defined in core/src/agents/invocation_context.ts:179

ReadonlynodeToolDepth

nodeToolDepth: number

Nesting depth of node-as-tool (NodeTool) executions in this invocation. Incremented each time a node runs as a tool (via a depth+1 clone), so NodeTool can bound node -> tool -> node recursion.

  • Defined in core/src/agents/invocation_context.ts:287

pluginManager

pluginManager: PluginManager

The manager for keeping track of plugins in this invocation.

  • Defined in core/src/agents/invocation_context.ts:257

OptionalrunConfig

runConfig?: RunConfig

Configurations for live agents under this invocation.

  • Defined in core/src/agents/invocation_context.ts:237

Readonlysession

session: Session

The current session of this invocation context.

  • Defined in core/src/agents/invocation_context.ts:221

Optional ReadonlysessionService

sessionService?: BaseSessionService
  • Defined in core/src/agents/invocation_context.ts:178

OptionaltranscriptionCache

transcriptionCache?: TranscriptionEntry[]

Caches necessary, data audio or contents, that are needed by transcription.

  • Defined in core/src/agents/invocation_context.ts:232

Optional ReadonlyuserContent

userContent?: Content

The user content that started this invocation.

  • Defined in core/src/agents/invocation_context.ts:216

OptionalworkflowInstructionScope

workflowInstructionScope?: WorkflowInstructionScope

Workflow: field-resolution scope for {Class.field} / <Class.field from node> instruction placeholders (set by LLMAgentWrapper).

  • Defined in core/src/agents/invocation_context.ts:274

Accessors

appName

  • get appName(): string

    The app name of the current session.

    Returns string

    • Defined in core/src/agents/invocation_context.ts:346

userId

  • get userId(): string

    The user ID of the current session.

    Returns string

    • Defined in core/src/agents/invocation_context.ts:353

Methods

clone

  • clone(overrides?: Partial<InvocationContextParams>): InvocationContext

    Returns a copy of this context with overrides applied. The spread carries every own field over (including the shared cost manager), so the copy keeps a single LLM-call counter for the invocation.

    Note: this copies own enumerable fields by value — scalar mutable fields (e.g. endInvocation) are decoupled from the original, while object-valued fields (session, …) stay shared by reference.

    Parameters

    • overrides: Partial<InvocationContextParams> = {}

    Returns InvocationContext

    • Defined in core/src/agents/invocation_context.ts:375

incrementLlmCallCount

  • incrementLlmCallCount(): void

    Tracks number of llm calls made.

    Returns void

    Throws

    If number of llm calls made exceed the set threshold.

    • Defined in core/src/agents/invocation_context.ts:362
Constructors
constructor
Properties
a2aMetadataabortSignalactiveStreamingToolsagentartifactServicebranchcredentialServiceendInvocationeventQueueinvocationIdisolationScopeliveRequestQueueliveSessionResumptionHandlememoryServicenodeToolDepthpluginManagerrunConfigsessionsessionServicetranscriptionCacheuserContentworkflowInstructionScope
Accessors
appNameuserId
Methods
cloneincrementLlmCallCount
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.