AguiAgentAdapter
public class AguiAgentAdapter
io/agentscope/core/agui/adapter/AguiAgentAdapter.java:80–771AGUI 智能体适配器,在智能体、模型与前端之间传递结构化消息和事件。位于 io.agentscope.core.agui.adapter 包。核心成员包括 run、buildRuntimeContext、AguiAgentAdapter、RUNTIME_CONTEXT_THREAD_ID_KEY、RUNTIME_CONTEXT_RUN_ID_KEY、RUNTIME_CONTEXT_MESSAGES_KEY。
Adapter that bridges AgentScope agents to the AG-UI protocol.
This adapter converts AG-UI protocol inputs to AgentScope messages, invokes the agent, and converts the streaming events back to AG-UI events.
Event Mapping:
-
AgentScope REASONING/SUMMARY events → AG-UI TEXT_MESSAGE_* events (for TextBlock)
-
AgentScope REASONING/SUMMARY events → AG-UI REASONING_* events (for ThinkingBlock, when enabled)
-
AgentScope TOOL_RESULT events → AG-UI TOOL_CALL_END events
-
ToolUseBlock content → AG-UI TOOL_CALL_START events
Reasoning Support:
-
ThinkingBlock content is converted to REASONING_* events according to AG-UI Reasoning draft
-
Reasoning output is disabled by default (enableReasoning=false) for backward compatibility
-
Set enableReasoning=true in AguiAdapterConfig to enable reasoning events
字段摘要Field Summary
| 字段Field | 类型Type | 说明Description |
|---|---|---|
RUNTIME_CONTEXT_THREAD_ID_KEYstaticfinal | String | 运行时上下文会话线程标识键字段。 The RUNTIME CONTEXT THREAD ID KEY field. |
RUNTIME_CONTEXT_RUN_ID_KEYstaticfinal | String | 运行时上下文运行标识键字段。 The RUNTIME CONTEXT RUN ID KEY field. |
RUNTIME_CONTEXT_MESSAGES_KEYstaticfinal | String | 运行时上下文消息键字段。 The RUNTIME CONTEXT MESSAGES KEY field. |
RUNTIME_CONTEXT_TOOLS_KEYstaticfinal | String | 运行时上下文工具键字段。 The RUNTIME CONTEXT TOOLS KEY field. |
RUNTIME_CONTEXT_CONTEXT_KEYstaticfinal | String | 运行时上下文上下文键字段。 The RUNTIME CONTEXT CONTEXT KEY field. |
RUNTIME_CONTEXT_STATE_KEYstaticfinal | String | 运行时上下文状态键字段。 The RUNTIME CONTEXT STATE KEY field. |
RUNTIME_CONTEXT_FORWARDED_PROPS_KEYstaticfinal | String | 运行时上下文 FORWARDED PROPS 键字段。 The RUNTIME CONTEXT FORWARDED PROPS KEY field. |
RUNTIME_CONTEXT_RESUME_KEYstaticfinal | String | 运行时上下文恢复键字段。 The RUNTIME CONTEXT RESUME KEY field. |
RUNTIME_CONTEXT_RESUME_INTERRUPTS_KEYstaticfinal | String | 运行时上下文恢复 INTERRUPTS 键字段。 The RUNTIME CONTEXT RESUME INTERRUPTS KEY field. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public AguiAgentAdapter(Agent agent, AguiAdapterConfig config) | 创建新的AguiAgentAdapter。 Creates a new AguiAgentAdapter. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Flux<AguiEvent> run(RunAgentInput input) | 设置运行。 Run the agent with AG-UI protocol input. |
public Flux<AguiEvent> run(RunAgentInput input, RuntimeContext runtimeContext) | 执行运行相关操作。 Run the agent with AG-UI protocol input and caller-provided runtime context. |
protected RuntimeContext buildRuntimeContext(RunAgentInput input, RuntimeContext runtimeContext) | 构建运行时上下文。 Build the runtime context used for the agent invocation. |
字段详情Field Detail
RUNTIME_CONTEXT_THREAD_ID_KEY
public static final String RUNTIME_CONTEXT_THREAD_ID_KEY
运行时上下文会话线程标识键字段。声明为 public static final String RUNTIME_CONTEXT_THREAD_ID_KEY。
The RUNTIME CONTEXT THREAD ID KEY field.
io/agentscope/core/agui/adapter/AguiAgentAdapter.java:82RUNTIME_CONTEXT_RUN_ID_KEY
public static final String RUNTIME_CONTEXT_RUN_ID_KEY
运行时上下文运行标识键字段。声明为 public static final String RUNTIME_CONTEXT_RUN_ID_KEY。
The RUNTIME CONTEXT RUN ID KEY field.
io/agentscope/core/agui/adapter/AguiAgentAdapter.java:83RUNTIME_CONTEXT_MESSAGES_KEY
public static final String RUNTIME_CONTEXT_MESSAGES_KEY
运行时上下文消息键字段。声明为 public static final String RUNTIME_CONTEXT_MESSAGES_KEY。
The RUNTIME CONTEXT MESSAGES KEY field.
io/agentscope/core/agui/adapter/AguiAgentAdapter.java:84RUNTIME_CONTEXT_TOOLS_KEY
public static final String RUNTIME_CONTEXT_TOOLS_KEY
运行时上下文工具键字段。声明为 public static final String RUNTIME_CONTEXT_TOOLS_KEY。
The RUNTIME CONTEXT TOOLS KEY field.
io/agentscope/core/agui/adapter/AguiAgentAdapter.java:85RUNTIME_CONTEXT_CONTEXT_KEY
public static final String RUNTIME_CONTEXT_CONTEXT_KEY
运行时上下文上下文键字段。声明为 public static final String RUNTIME_CONTEXT_CONTEXT_KEY。
The RUNTIME CONTEXT CONTEXT KEY field.
io/agentscope/core/agui/adapter/AguiAgentAdapter.java:86RUNTIME_CONTEXT_STATE_KEY
public static final String RUNTIME_CONTEXT_STATE_KEY
运行时上下文状态键字段。声明为 public static final String RUNTIME_CONTEXT_STATE_KEY。
The RUNTIME CONTEXT STATE KEY field.
io/agentscope/core/agui/adapter/AguiAgentAdapter.java:87RUNTIME_CONTEXT_FORWARDED_PROPS_KEY
public static final String RUNTIME_CONTEXT_FORWARDED_PROPS_KEY
运行时上下文 FORWARDED PROPS 键字段。声明为 public static final String RUNTIME_CONTEXT_FORWARDED_PROPS_KEY。
The RUNTIME CONTEXT FORWARDED PROPS KEY field.
io/agentscope/core/agui/adapter/AguiAgentAdapter.java:88RUNTIME_CONTEXT_RESUME_KEY
public static final String RUNTIME_CONTEXT_RESUME_KEY
运行时上下文恢复键字段。声明为 public static final String RUNTIME_CONTEXT_RESUME_KEY。
The RUNTIME CONTEXT RESUME KEY field.
io/agentscope/core/agui/adapter/AguiAgentAdapter.java:89RUNTIME_CONTEXT_RESUME_INTERRUPTS_KEY
public static final String RUNTIME_CONTEXT_RESUME_INTERRUPTS_KEY
运行时上下文恢复 INTERRUPTS 键字段。声明为 public static final String RUNTIME_CONTEXT_RESUME_INTERRUPTS_KEY。
The RUNTIME CONTEXT RESUME INTERRUPTS KEY field.
io/agentscope/core/agui/adapter/AguiAgentAdapter.java:90构造器详情Constructor Detail
AguiAgentAdapter
public AguiAgentAdapter(Agent agent, AguiAdapterConfig config)
创建新的AguiAgentAdapter。
Creates a new AguiAgentAdapter.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agent | Agent | 智能体(类型 `Agent`)。The agent to adapt |
config | AguiAdapterConfig | 适配器配置。The adapter configuration |
io/agentscope/core/agui/adapter/AguiAgentAdapter.java:104–114方法详情Method Detail
run
public Flux<AguiEvent> run(RunAgentInput input)
设置运行。
Run the agent with AG-UI protocol input.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
input | RunAgentInput | AG-UI 运行输入。The AG-UI run input |
Flux<AguiEvent>io/agentscope/core/agui/adapter/AguiAgentAdapter.java:125–127run
public Flux<AguiEvent> run(RunAgentInput input, RuntimeContext runtimeContext)
执行运行相关操作。
Run the agent with AG-UI protocol input and caller-provided runtime context.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
input | RunAgentInput | AG-UI 运行输入。The AG-UI run input |
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。Optional caller-provided runtime context |
Flux<AguiEvent>io/agentscope/core/agui/adapter/AguiAgentAdapter.java:140–189buildRuntimeContext
protected RuntimeContext buildRuntimeContext(RunAgentInput input, RuntimeContext runtimeContext)
构建运行时上下文。
Build the runtime context used for the agent invocation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
input | RunAgentInput | AG-UI 运行输入。The AG-UI run input |
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。Optional caller-provided runtime context |
RuntimeContextio/agentscope/core/agui/adapter/AguiAgentAdapter.java:291–307