类的用途(Uses of the Class)
com.google.adk.agents.InvocationContext
Packages that use InvocationContext
Package
Description
-
**用途:** InvocationContext 在……里面;处于……状态 com.google.adk.a2a.agent
Methods in com.google.adk.a2a.agent with parameters of type InvocationContextModifier and TypeMethodDescriptionprotected io.reactivex.rxjava3.core.Flowable<Event> RemoteA2AAgent.runAsyncImpl(InvocationContext invocationContext) protected io.reactivex.rxjava3.core.Flowable<Event> RemoteA2AAgent.runLiveImpl(InvocationContext invocationContext) -
**用途:** InvocationContext 在……里面;处于……状态 com.google.adk.a2a.converters
Methods in com.google.adk.a2a.converters with parameters of type InvocationContextModifier and TypeMethodDescriptionstatic EventResponseConverter.artifactToEvent(io.a2a.spec.Artifact artifact, InvocationContext invocationContext) 将某个“artifact”(工件/数据对象)转换为 ADK(Application Development Kit)事件。ResponseConverter.clientEventToEvent(io.a2a.client.ClientEvent event, InvocationContext invocationContext) 将 A2A 请求转换为另一种格式。ClientEvent发送到一个 ADK(Application Development Kit,应用程序开发工具包)Event根据事件类型(event type)来决定相应的处理方式。static com.google.common.collect.ImmutableList<io.a2a.spec.Part<?>> EventConverter.messagePartsFromContext(InvocationContext context) 从上下文事件中提取出应该发送给代理(agent)的数据部分。static EventResponseConverter.messageToEvent(io.a2a.spec.Message message, InvocationContext invocationContext) 将 A2A 消息转换回 ADK 事件。static EventResponseConverter.messageToEvent(io.a2a.spec.Message message, InvocationContext invocationContext, boolean isPending) 将 A2A 消息转换回 ADK 事件。static EventResponseConverter.messageToFailedEvent(io.a2a.spec.Message message, InvocationContext invocationContext) 将因任务失败而产生的 A2A(点对点)消息转换为 ADK(应用开发框架)事件,并在事件中填充相应的错误信息。static EventResponseConverter.taskToEvent(io.a2a.spec.Task task, InvocationContext invocationContext) 将 A2A 请求转换为另一种格式或类型。Task发送到一个 ADK(Application Development Kit,应用程序开发工具包)Event. -
**用途:** InvocationContext 在……里面;处于……状态 com.google.adk.agents
Fields in com.google.adk.agents declared as InvocationContextModifier and TypeFieldDescriptionprotected final InvocationContextReadonlyContext.invocationContextMethods in com.google.adk.agents that return InvocationContextModifier and TypeMethodDescriptionInvocationContext.Builder.build()构建(Builds the)InvocationContext`instance.`PlanningContext.invocationContext()返回完整的(内容)。InvocationContext适用于高级使用场景。ReadonlyContext.invocationContext()返回调用上下文( invocation context)。Methods in com.google.adk.agents with parameters of type InvocationContextModifier and TypeMethodDescriptionCallbacks.AfterToolCallback.call(InvocationContext invocationContext, BaseTool baseTool, Map<String, Object> input, ToolContext toolContext, Object response) 工具运行完成后会触发异步回调函数。Callbacks.AfterToolCallbackSync.call(InvocationContext invocationContext, BaseTool baseTool, Map<String, Object> input, ToolContext toolContext, Object response) Callbacks.BeforeToolCallback.call(InvocationContext invocationContext, BaseTool baseTool, Map<String, Object> input, ToolContext toolContext) 在工具运行之前执行的异步回调函数。Callbacks.BeforeToolCallbackSync.call(InvocationContext invocationContext, BaseTool baseTool, Map<String, Object> input, ToolContext toolContext) Callbacks.OnToolErrorCallback.call(InvocationContext invocationContext, BaseTool baseTool, Map<String, Object> input, ToolContext toolContext, Exception error) 当工具调用失败时,会触发异步回调函数。Callbacks.OnToolErrorCallbackSync.call(InvocationContext invocationContext, BaseTool baseTool, Map<String, Object> input, ToolContext toolContext, Exception error) io.reactivex.rxjava3.core.Flowable<Event> BaseAgent.runAsync(InvocationContext parentContext) 异步运行代理程序。io.reactivex.rxjava3.core.Flowable<Event> NodeViewAgent.runAsync(InvocationContext parentContext) protected abstract io.reactivex.rxjava3.core.Flowable<Event> BaseAgent.runAsyncImpl(InvocationContext invocationContext) 与特定代理(Agent)相关的异步逻辑(Agent-specific asynchronous logic)。protected io.reactivex.rxjava3.core.Flowable<Event> LlmAgent.runAsyncImpl(InvocationContext invocationContext) protected io.reactivex.rxjava3.core.Flowable<Event> LoopAgent.runAsyncImpl(InvocationContext invocationContext) protected io.reactivex.rxjava3.core.Flowable<Event> NodeViewAgent.runAsyncImpl(InvocationContext invocationContext) protected io.reactivex.rxjava3.core.Flowable<Event> ParallelAgent.runAsyncImpl(InvocationContext invocationContext) 并行运行子代理(sub-agents),并收集它们产生的事件数据。protected io.reactivex.rxjava3.core.Flowable<Event> PlannerAgent.runAsyncImpl(InvocationContext invocationContext) protected io.reactivex.rxjava3.core.Flowable<Event> SequentialAgent.runAsyncImpl(InvocationContext invocationContext) 按顺序运行子代理(sub-agents)。io.reactivex.rxjava3.core.Flowable<Event> BaseAgent.runLive(InvocationContext parentContext) 同步运行代理程序。io.reactivex.rxjava3.core.Flowable<Event> NodeViewAgent.runLive(InvocationContext parentContext) protected abstract io.reactivex.rxjava3.core.Flowable<Event> BaseAgent.runLiveImpl(InvocationContext invocationContext) 与特定代理相关的同步逻辑(Agent-specific synchronous logic)。protected io.reactivex.rxjava3.core.Flowable<Event> LlmAgent.runLiveImpl(InvocationContext invocationContext) protected io.reactivex.rxjava3.core.Flowable<Event> LoopAgent.runLiveImpl(InvocationContext invocationContext) protected io.reactivex.rxjava3.core.Flowable<Event> NodeViewAgent.runLiveImpl(InvocationContext invocationContext) protected io.reactivex.rxjava3.core.Flowable<Event> ParallelAgent.runLiveImpl(InvocationContext invocationContext) ParallelAgent 不支持该功能。protected io.reactivex.rxjava3.core.Flowable<Event> PlannerAgent.runLiveImpl(InvocationContext invocationContext) protected io.reactivex.rxjava3.core.Flowable<Event> SequentialAgent.runLiveImpl(InvocationContext invocationContext) 在实时模式下,按顺序依次运行子代理(sub-agents)。Constructors in com.google.adk.agents with parameters of type InvocationContextModifierConstructorDescriptionCallbackContext(InvocationContext invocationContext, @Nullable EventActions eventActions) 初始化回调函数的上下文(即调用该回调函数时的环境或数据)。CallbackContext(InvocationContext invocationContext, @Nullable EventActions eventActions, @Nullable String eventId) 初始化回调函数的上下文(即调用该回调函数时的环境或数据)。Context(InvocationContext invocationContext, NodeExecutionState nodeState) 创建工作流节点运行的上下文环境;该节点的状态为(此处应填写具体的状态信息)。nodeState.PlanningContext(InvocationContext invocationContext, com.google.common.collect.ImmutableList<BaseAgent> availableAgents) ReadonlyContext(InvocationContext invocationContext) -
**用途:** InvocationContext 在……里面;处于……状态 com.google.adk.codeexecutors
Methods in com.google.adk.codeexecutors with parameters of type InvocationContextModifier and TypeMethodDescriptionBaseCodeExecutor.executeCode(InvocationContext invocationContext, CodeExecutionUtils.CodeExecutionInput codeExecutionInput) 执行代码并返回代码执行的结果。BuiltInCodeExecutor.executeCode(InvocationContext invocationContext, CodeExecutionUtils.CodeExecutionInput codeExecutionInput) ContainerCodeExecutor.executeCode(InvocationContext invocationContext, CodeExecutionUtils.CodeExecutionInput codeExecutionInput) VertexAiCodeExecutor.executeCode(InvocationContext invocationContext, CodeExecutionUtils.CodeExecutionInput codeExecutionInput) -
**用途:** InvocationContext 在……里面;处于……状态 com.google.adk.flows
Methods in com.google.adk.flows with parameters of type InvocationContextModifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Flowable<Event> BaseFlow.run(InvocationContext invocationContext) 运行这个流程。default io.reactivex.rxjava3.core.Flowable<Event> BaseFlow.runLive(InvocationContext invocationContext) -
**用途:** InvocationContext 在……里面;处于……状态 com.google.adk.flows.llmflows
Methods in com.google.adk.flows.llmflows with parameters of type InvocationContextModifier and TypeMethodDescriptionstatic io.reactivex.rxjava3.core.CompletablePersistBarrier.awaitPersisted(InvocationContext context, List<Event> events) 每次事件发生时,该操作都会被执行一次。events已经被PersistBarrier.markPersisted(InvocationContext, String)如果其中任何一个步骤失败,那么整个操作也会失败。PersistBarrier.markFailed(InvocationContext, String, Throwable);如果该“障碍”(即阻止进程继续执行的因素)从未存在过,那么操作会立即完成。PersistBarrier.enable(InvocationContext)d.static EventOutputSchema.createFinalModelResponseEvent(InvocationContext context, String jsonResponse) 从 `set_model_response` JSON 数据中生成最终的模型响应事件。static voidPersistBarrier.enable(InvocationContext context) 表示“某个标记”或“某个符号”的含义。Runner它负责触发此次调用,并会处理所有被追加的事件(即这些事件会被相应地处理或解决)。Functions.generateRequestConfirmationEvent(InvocationContext invocationContext, Event functionCallEvent, Event functionResponseEvent) 从函数响应事件中生成一个请求确认事件。static io.reactivex.rxjava3.core.Maybe<Event> Functions.handleFunctionCalls(InvocationContext invocationContext, Event functionCallEvent, Map<String, BaseTool> tools) 处理标准的、非流式的函数调用。static io.reactivex.rxjava3.core.Maybe<Event> Functions.handleFunctionCalls(InvocationContext invocationContext, Event functionCallEvent, Map<String, BaseTool> tools, Map<String, ToolConfirmation> toolConfirmations) 处理标准(非流式)函数调用,并提供相应的工具确认功能。static io.reactivex.rxjava3.core.Maybe<Event> Functions.handleFunctionCallsLive(InvocationContext invocationContext, Event functionCallEvent, Map<String, BaseTool> tools) 用于处理实时/流式环境中的函数调用,支持后台执行以及流的终止。static io.reactivex.rxjava3.core.Maybe<Event> Functions.handleFunctionCallsLive(InvocationContext invocationContext, Event functionCallEvent, Map<String, BaseTool> tools, Map<String, ToolConfirmation> toolConfirmations) 该组件能够在实时/流式环境中处理函数调用,并提供相应的工具确认功能;同时支持后台执行以及流的终止操作。static voidPersistBarrier.markFailed(InvocationContext context, String eventId, Throwable error) 这些信号表明:尝试使用给定的 ID 继续执行该事件时发生了失败,因此对该事件的 `await` 操作也会失败。error而不是永远被阻止(或:无法正常使用)。static voidPersistBarrier.markPersisted(InvocationContext context, String eventId) 这些信号表明……Runner使用给定的 ID 保存了该事件。protected io.reactivex.rxjava3.core.Flowable<Event> BaseLlmFlow.postprocess(InvocationContext context, Event baseEventForLlmResponse, LlmRequest llmRequest, LlmResponse llmResponse, io.opentelemetry.context.Context parentContext) 在从大型语言模型(LLM)接收到响应后,会对该响应进行后处理。io.reactivex.rxjava3.core.Single<RequestProcessor.RequestProcessingResult> AgentTransfer.processRequest(InvocationContext context, LlmRequest request) io.reactivex.rxjava3.core.Single<RequestProcessor.RequestProcessingResult> Basic.processRequest(InvocationContext context, LlmRequest request) io.reactivex.rxjava3.core.Single<RequestProcessor.RequestProcessingResult> Compaction.processRequest(InvocationContext context, LlmRequest request) io.reactivex.rxjava3.core.Single<RequestProcessor.RequestProcessingResult> Contents.processRequest(InvocationContext context, LlmRequest request) io.reactivex.rxjava3.core.Single<RequestProcessor.RequestProcessingResult> Identity.processRequest(InvocationContext context, LlmRequest request) io.reactivex.rxjava3.core.Single<RequestProcessor.RequestProcessingResult> Instructions.processRequest(InvocationContext context, LlmRequest request) io.reactivex.rxjava3.core.Single<RequestProcessor.RequestProcessingResult> OutputSchema.processRequest(InvocationContext context, LlmRequest request) io.reactivex.rxjava3.core.Single<RequestProcessor.RequestProcessingResult> RequestConfirmationLlmRequestProcessor.processRequest(InvocationContext invocationContext, LlmRequest llmRequest) io.reactivex.rxjava3.core.Single<RequestProcessor.RequestProcessingResult> RequestProcessor.processRequest(InvocationContext context, LlmRequest request) 将 LLM 请求作为预处理阶段的一部分进行处理。io.reactivex.rxjava3.core.Single<ResponseProcessor.ResponseProcessingResult> ResponseProcessor.processResponse(InvocationContext context, LlmResponse response) 将大型语言模型(LLM)的响应作为后处理阶段的一部分进行处理。io.reactivex.rxjava3.core.Flowable<Event> BaseLlmFlow.run(InvocationContext invocationContext) 通过反复调用相关函数,执行整个大型语言模型(LLM)的运行流程。BaseLlmFlow.runOneStep(Context, InvocationContext)直到收到最终的回复为止。io.reactivex.rxjava3.core.Flowable<Event> BaseLlmFlow.runLive(InvocationContext invocationContext) 以流式模式执行大型语言模型(LLM)的相关流程。 -
**用途:** InvocationContext 在……里面;处于……状态 com.google.adk.plugins
Methods in com.google.adk.plugins with parameters of type InvocationContextModifier and TypeMethodDescriptionio.reactivex.rxjava3.core.CompletableDebugLoggingPlugin.afterRunCallback(InvocationContext invocationContext) io.reactivex.rxjava3.core.CompletableLoggingPlugin.afterRunCallback(InvocationContext invocationContext) default io.reactivex.rxjava3.core.CompletablePlugin.afterRunCallback(InvocationContext invocationContext) 在 ADK 运行器完成运行后,会执行该回调函数。io.reactivex.rxjava3.core.CompletablePluginManager.afterRunCallback(InvocationContext invocationContext) io.reactivex.rxjava3.core.CompletableReflectAndRetryToolPlugin.afterRunCallback(InvocationContext invocationContext) 会清除已终止的调用所记录的失败次数(即失败记录)。io.reactivex.rxjava3.core.CompletableReplayPlugin.afterRunCallback(InvocationContext invocationContext) io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> DebugLoggingPlugin.beforeRunCallback(InvocationContext invocationContext) io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> LoggingPlugin.beforeRunCallback(InvocationContext invocationContext) default io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> Plugin.beforeRunCallback(InvocationContext invocationContext) 回调函数在 ADK 运行程序启动之前被执行。io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> PluginManager.beforeRunCallback(InvocationContext invocationContext) io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> ReplayPlugin.beforeRunCallback(InvocationContext invocationContext) io.reactivex.rxjava3.core.Maybe<Event> DebugLoggingPlugin.onEventCallback(InvocationContext invocationContext, Event event) io.reactivex.rxjava3.core.Maybe<Event> LoggingPlugin.onEventCallback(InvocationContext invocationContext, Event event) default io.reactivex.rxjava3.core.Maybe<Event> Plugin.onEventCallback(InvocationContext invocationContext, Event event) 在事件从运行器(runner)中被处理/执行后,会触发相应的回调函数(Callback)。io.reactivex.rxjava3.core.Maybe<Event> PluginManager.onEventCallback(InvocationContext invocationContext, Event event) default io.reactivex.rxjava3.core.CompletablePlugin.onRunErrorCallback(InvocationContext invocationContext, Throwable error) 当运行过程中遇到错误时,会执行此回调函数。io.reactivex.rxjava3.core.CompletablePluginManager.onRunErrorCallback(InvocationContext invocationContext, Throwable error) io.reactivex.rxjava3.core.CompletableReflectAndRetryToolPlugin.onRunErrorCallback(InvocationContext invocationContext, Throwable error) 会清除那些失败调用对应的失败记录(即失败次数)。io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> DebugLoggingPlugin.onUserMessageCallback(InvocationContext invocationContext, com.google.genai.types.Content userMessage) io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> LoggingPlugin.onUserMessageCallback(InvocationContext invocationContext, @Nullable com.google.genai.types.Content userMessage) default io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> Plugin.onUserMessageCallback(InvocationContext invocationContext, com.google.genai.types.Content userMessage) 当在调用开始之前接收到用户消息时,会执行此回调函数。io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> PluginManager.onUserMessageCallback(InvocationContext invocationContext, com.google.genai.types.Content userMessage) io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> SaveFilesAsArtifactsPlugin.onUserMessageCallback(InvocationContext invocationContext, com.google.genai.types.Content userMessage) io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> PluginManager.runBeforeRunCallback(InvocationContext invocationContext) io.reactivex.rxjava3.core.CompletablePluginManager.runOnRunErrorCallback(InvocationContext invocationContext, Throwable error) io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> PluginManager.runOnUserMessageCallback(InvocationContext invocationContext, com.google.genai.types.Content userMessage) -
**用途:** InvocationContext 在……里面;处于……状态 com.google.adk.plugins.agentanalytics
Methods in com.google.adk.plugins.agentanalytics with parameters of type InvocationContextModifier and TypeMethodDescriptionio.reactivex.rxjava3.core.CompletableBigQueryAgentAnalyticsPlugin.afterRunCallback(InvocationContext invocationContext) TraceManager.attachCurrentSpan(InvocationContext context) 该插件会记录 OpenTelemetry 环境中的所有 Span 的 ID,并将这些 ID 作为调用根(invocation root)进行存储,而不会创建或拥有任何新的 Span。因此,插件生成的记录数据可以与主机现有的跟踪数据(tracing data)进行关联。io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> BigQueryAgentAnalyticsPlugin.beforeRunCallback(InvocationContext invocationContext) voidTraceManager.ensureInvocationSpan(InvocationContext context) com.google.adk.plugins.agentanalytics.TraceManager.SpanIdsTraceManager.getCurrentSpanAndParent(InvocationContext context) TraceManager.getCurrentSpanId(InvocationContext context) TraceManager.getTraceId(InvocationContext context) voidTraceManager.initTrace(InvocationContext context) voidTraceManager.initTraceIfNeeded(InvocationContext context) 如果根代理名称仍使用默认值(即哨兵代理的名称),则从调用上下文中设置该名称。io.reactivex.rxjava3.core.Maybe<Event> BigQueryAgentAnalyticsPlugin.onEventCallback(InvocationContext invocationContext, Event event) io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> BigQueryAgentAnalyticsPlugin.onUserMessageCallback(InvocationContext invocationContext, com.google.genai.types.Content userMessage) Optional<com.google.adk.plugins.agentanalytics.TraceManager.RecordData> TraceManager.popSpan(InvocationContext context, String expectedKindPrefix) 如果调用分支的顶级 Span 记录的类型与预期匹配,则会显示该记录。expectedKindPrefix.Optional<com.google.adk.plugins.agentanalytics.TraceManager.RecordData> TraceManager.popSpan(InvocationContext context, String expectedKindPrefix, @Nullable String operationId) 会显示调用该分支的代码段(即“span record”)的相关信息。TraceManager.pushSpan(InvocationContext context, String spanName) 将一个仅包含 ID 的 Span 记录压入调用方的栈(stack)中。 -
**用途:** InvocationContext 在……里面;处于……状态 com.google.adk.telemetry
Methods in com.google.adk.telemetry that return InvocationContextModifier and TypeMethodDescriptionInstrumentation.AgentInvocation.getCtx()检索与此代理调用相关联的调用上下文( invocation context)。Methods in com.google.adk.telemetry with parameters of type InvocationContextModifier and TypeMethodDescriptionInstrumentation.recordAgentInvocation(InvocationContext ctx, BaseAgent agent) 已弃用(Deprecated)。请改用那些明确指定了父上下文的版本。Instrumentation.recordAgentInvocation(InvocationContext ctx, BaseAgent agent, io.opentelemetry.context.Context parentContext) 创建一个……Instrumentation.AgentInvocation用于记录代理调用遥测数据的上下文环境,其中包含一个明确的父上下文(parent context)。static <T> Tracing.TracerProvider<T> Tracing.traceAgent(String spanName, String agentName, String agentDescription, InvocationContext invocationContext) 已弃用(Deprecated)。static voidTracing.traceAgentInvocation(io.opentelemetry.api.trace.Span span, String agentName, String agentDescription, InvocationContext invocationContext) 根据 OTEL semconv 版本 1.37 的规定,这些设置会立即应用于代理(agent)被调用时所具备的属性。static voidTracing.traceCallLlm(io.opentelemetry.api.trace.Span span, InvocationContext invocationContext, String eventId, LlmRequest llmRequest, LlmResponse llmResponse, @Nullable Exception error) 记录对大型语言模型(LLM)的调用过程。static voidTracing.traceSendData(io.opentelemetry.api.trace.Span span, InvocationContext invocationContext, String eventId, List<com.google.genai.types.Content> data) 记录数据(历史数据或新内容)被发送到代理/模型的过程。Constructors in com.google.adk.telemetry with parameters of type InvocationContextModifierConstructorDescriptionAgentInvocation(InvocationContext ctx, BaseAgent agent, io.opentelemetry.context.Context parentContext) 构建一个新的……AgentInvocation遥测范围(Telemetry Scope)。 -
**用途:** InvocationContext 在……里面;处于……状态 com.google.adk.tools
Methods in com.google.adk.tools with parameters of type InvocationContextModifier and TypeMethodDescriptionstatic ToolContext.BuilderToolContext.builder(InvocationContext invocationContext) FunctionTool.callLive(Map<String, Object> args, ToolContext toolContext, InvocationContext invocationContext) -
**用途:** InvocationContext 在……里面;处于……状态 com.google.adk.utils
Methods in com.google.adk.utils with parameters of type InvocationContextModifier and TypeMethodDescriptionstatic io.reactivex.rxjava3.core.Single<String> InstructionUtils.injectSessionState(InvocationContext context, String template) 使用会话状态中的数据或已加载的资源(artifacts),填充指令模板字符串中的占位符(placeholders)。 -
**用途:** InvocationContext 在……里面;处于……状态 com.google.adk.workflow
Methods in com.google.adk.workflow with parameters of type InvocationContextModifier and TypeMethodDescriptionstatic io.reactivex.rxjava3.core.Flowable<Event> NodeRunner.runRoot(Node node, InvocationContext context, Function<? super Event, ? extends io.reactivex.rxjava3.core.Single<Event>> processEvent) 运行node作为……的根源;作为……的基础context在调用过程中,会处理用户提供的内容,并将每个事件依次传递下去(即:每个事件都会被依次处理)。processEvent(表示事情按计划进行或按预期发展)很好;只是……Runner应该调用这个方法。