Class InvocationContext
java.lang.Object
com.google.adk.agents.InvocationContext
The context for an agent invocation.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInvocationContext(BaseSessionService sessionService, BaseArtifactService artifactService, BaseMemoryService memoryService, Plugin pluginManager, Optional<LiveRequestQueue> liveRequestQueue, Optional<String> branch, String invocationId, BaseAgent agent, Session session, Optional<com.google.genai.types.Content> userContent, RunConfig runConfig, boolean endInvocation) Deprecated, for removal: This API element is subject to removal in a future version.InvocationContext(BaseSessionService sessionService, BaseArtifactService artifactService, BaseMemoryService memoryService, Optional<LiveRequestQueue> liveRequestQueue, Optional<String> branch, String invocationId, BaseAgent agent, Session session, Optional<com.google.genai.types.Content> userContent, RunConfig runConfig, boolean endInvocation) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()instead. -
Method Summary
Modifier and TypeMethodDescriptionReturns a map of tool call IDs to active streaming tools for the current invocation.agent()Returns the agent being invoked.voidDeprecated, for removal: This API element is subject to removal in a future version.UsetoBuilder()andInvocationContext.Builder.agent(BaseAgent)instead.appName()Returns the application name associated with the session.Returns the artifact service for persisting artifacts.branch()Returns the branch ID for the current invocation, if one is set.voidSets the [branch] ID for the current invocation.static InvocationContext.Builderbuilder()Returns a newInvocationContext.Builderfor creatingInvocationContextinstances.Returns a map for storing temporary context data that can be shared between different parts of the invocation (e.g., before/on/after model callbacks).Returns the context cache configuration for the current agent run.static InvocationContextcopyOf(InvocationContext other) Deprecated, for removal: This API element is subject to removal in a future version.Useother.toBuilder().build()instead.static InvocationContextcreate(BaseSessionService sessionService, BaseArtifactService artifactService, BaseAgent agent, Session session, LiveRequestQueue liveRequestQueue, RunConfig runConfig) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()instead.static InvocationContextcreate(BaseSessionService sessionService, BaseArtifactService artifactService, String invocationId, BaseAgent agent, Session session, com.google.genai.types.Content userContent, RunConfig runConfig) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()instead.booleanReturns whether this invocation should be ended, e.g., due to reaching a terminal state or error.booleanReturns the events compaction configuration for the current agent run.inthashCode()voidIncrements the count of LLM calls made during this invocation and throws an exception if the limit defined inRunConfigis exceeded.Returns the unique ID for this invocation.Returns the queue for managing live requests, if available for this invocation.Returns the memory service for accessing agent memory.static StringGenerates a new unique ID for an invocation context.Returns the plugin manager for accessing tools and plugins.Returns the configuration for the current agent run.session()Returns the session associated with this invocation.Returns the session service for managing session state.voidsetEndInvocation(boolean endInvocation) Sets whether this invocation should be ended.Returns aInvocationContext.Builderinitialized with the values of this instance.Optional<com.google.genai.types.Content> Returns the user content that triggered this invocation, if any.userId()Returns the user ID associated with the session.
-
Constructor Details
-
InvocationContext
-
InvocationContext
@Deprecated(forRemoval=true) public InvocationContext(BaseSessionService sessionService, BaseArtifactService artifactService, BaseMemoryService memoryService, Plugin pluginManager, Optional<LiveRequestQueue> liveRequestQueue, Optional<String> branch, String invocationId, BaseAgent agent, Session session, Optional<com.google.genai.types.Content> userContent, RunConfig runConfig, boolean endInvocation) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()instead. -
InvocationContext
@Deprecated(forRemoval=true) public InvocationContext(BaseSessionService sessionService, BaseArtifactService artifactService, BaseMemoryService memoryService, Optional<LiveRequestQueue> liveRequestQueue, Optional<String> branch, String invocationId, BaseAgent agent, Session session, Optional<com.google.genai.types.Content> userContent, RunConfig runConfig, boolean endInvocation) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()instead.
-
-
Method Details
-
create
@InlineMe(replacement="InvocationContext.builder().sessionService(sessionService).artifactService(artifactService).invocationId(invocationId).agent(agent).session(session).userContent(Optional.ofNullable(userContent)).runConfig(runConfig).build()", imports={"com.google.adk.agents.InvocationContext","java.util.Optional"}) @Deprecated(forRemoval=true) public static InvocationContext create(BaseSessionService sessionService, BaseArtifactService artifactService, String invocationId, BaseAgent agent, Session session, com.google.genai.types.Content userContent, RunConfig runConfig) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()instead. -
create
@Deprecated(forRemoval=true) public static InvocationContext create(BaseSessionService sessionService, BaseArtifactService artifactService, BaseAgent agent, Session session, LiveRequestQueue liveRequestQueue, RunConfig runConfig) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()instead. -
builder
Returns a newInvocationContext.Builderfor creatingInvocationContextinstances. -
toBuilder
Returns aInvocationContext.Builderinitialized with the values of this instance. -
copyOf
Deprecated, for removal: This API element is subject to removal in a future version.Useother.toBuilder().build()instead.Creates a shallow copy of the givenInvocationContext. -
sessionService
Returns the session service for managing session state. -
artifactService
Returns the artifact service for persisting artifacts. -
memoryService
Returns the memory service for accessing agent memory. -
pluginManager
Returns the plugin manager for accessing tools and plugins. -
activeStreamingTools
Returns a map of tool call IDs to active streaming tools for the current invocation. -
liveRequestQueue
Returns the queue for managing live requests, if available for this invocation. -
invocationId
Returns the unique ID for this invocation. -
branch
Sets the [branch] ID for the current invocation. A branch represents a fork in the conversation history. -
branch
-
agent
Returns the agent being invoked. -
agent
Deprecated, for removal: This API element is subject to removal in a future version.UsetoBuilder()andInvocationContext.Builder.agent(BaseAgent)instead.Sets the [agent] being invoked. This is useful when delegating to a sub-agent. -
session
Returns the session associated with this invocation. -
userContent
Returns the user content that triggered this invocation, if any. -
runConfig
Returns the configuration for the current agent run. -
callbackContextData
-
endInvocation
public boolean endInvocation()Returns whether this invocation should be ended, e.g., due to reaching a terminal state or error. -
setEndInvocation
public void setEndInvocation(boolean endInvocation) Sets whether this invocation should be ended. -
appName
Returns the application name associated with the session. -
userId
Returns the user ID associated with the session. -
newInvocationContextId
Generates a new unique ID for an invocation context. -
incrementLlmCallsCount
Increments the count of LLM calls made during this invocation and throws an exception if the limit defined inRunConfigis exceeded.- Throws:
LlmCallsLimitExceededException- if the call limit is exceeded
-
eventsCompactionConfig
Returns the events compaction configuration for the current agent run. -
contextCacheConfig
Returns the context cache configuration for the current agent run. -
equals
-
hashCode
-
builder()instead.