调用(即程序中执行某段代码的行为)上下文(Context)
An invocation context represents the data of a single invocation of an agent.
An invocation:
Starts with a user message and ends with a final response.
Can contain one or multiple agent calls.
Is handled by runner.run_async().
An invocation runs an agent until it does not request to transfer to another agent.
An agent call:
Is handled by agent.run().
Ends when agent.run() 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:
A final response is generated.
The agent transfers to another agent.
The end_invocation is set to true by any callbacks or tools.
A step:
Calls the LLM only once and yields its response.
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 the end_invocation 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]构造函数(Constructors)
1.1.0 版本的构造函数(constructor)没有任何特殊功能(即没有实现任何特定的逻辑或方法)。 node该构造函数仍然可见,因为 `javac` 会跳过那些被标记为“隐藏”的构造函数;因此,如果使用 1.1.0 版本的 Java 编写代码,编译过程将会失败。
属性(Properties)
此次调用中代理的状态。
此调用的可选上下文缓存配置,该配置是从……传播而来的。 应用程序(App). 当……的时候 null此次调用中,上下文缓存(context caching)功能已被禁用。
本次调用中,每个代理的状态信息均已获取完毕。
此调用可配置事件压缩功能(可选)。
每个工具都具备以下功能: LlmAgent “在此上下文中运行”(run under this context)除了具有其自身的功能外,还提供了其他额外的优势或特性。 LlmAgent.tools为下属代理人复制的上下文环境会共享这张“地图”(即数据结构或信息模型),因此他们的工具也能访问这些数据。
每次调用时框架内部使用的数据(详见……) ContextFrameworkData该对象被作为一个专用的容器(holder)来使用,因此那些需要用户主动选择(opt-in)才能使用的成员(members)无法通过这个公共构造函数(public constructor)来创建对象。根据合同规定,这个对象本身并不属于公共 API(public API);不过,对这个对象的引用本身并不需要用户的主动选择(opt-in),但该对象的各个字段(fields)则需要用户的主动选择才能被使用。
此调用上下文的标识符。该属性为只读(read-only)。
是否结束此次调用。
返回当前调用是否可以恢复(即是否可以在中断后继续执行)。
负责在此次调用中跟踪插件状态的管理员。
此调用支持可选的可恢复性(resumability)配置。
触发此次调用的用户内容。该内容为只读(不可修改)。
函数
为子代理创建一个新的 `InvocationContext` 对象,该对象继承自当前上下文(`this context`)。同时,会将给定代理的名称添加到分支路径中。
在当前的函数调用过程中,查找与该函数响应 ID 匹配的函数调用事件。
从内存中返回当前会话的所有事件。 Session.events,其中 SessionService.appendEvent 这些数据会保持同步;程序会直接从内存中读取所需信息,而无需在每一步都重新从会话服务中获取数据。这一机制适用于 Python、Java 和 Go 语言编写的应用程序(ADK)。
该系统能够高效且安全地执行一系列函数调用(即处理这些函数调用)。
统计这次对大型语言模型(LLM)的调用次数,并执行相应的规则/操作。 RunConfig.maxLlmCalls.
如果当前的调用可以恢复(即可以继续执行),则该函数会更新代理的状态信息。
递归地重置指定代理的所有子代理的状态。
显式设置代理的状态;不会自动进行初始化。
返回一个布尔值,表示是否应在该事件发生后立即暂停函数的执行。