Class AguiAgentAdapter
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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAguiAgentAdapter(io.agentscope.core.agent.Agent agent, AguiAdapterConfig config) Creates a new AguiAgentAdapter. -
Method Summary
Modifier and TypeMethodDescriptionprotected io.agentscope.core.agent.RuntimeContextbuildRuntimeContext(RunAgentInput input, io.agentscope.core.agent.RuntimeContext runtimeContext) Build the runtime context used for the agent invocation.reactor.core.publisher.Flux<AguiEvent>run(RunAgentInput input) Run the agent with AG-UI protocol input.reactor.core.publisher.Flux<AguiEvent>run(RunAgentInput input, io.agentscope.core.agent.RuntimeContext runtimeContext) Run the agent with AG-UI protocol input and caller-provided runtime context.
-
Field Details
-
RUNTIME_CONTEXT_THREAD_ID_KEY
- See Also:
-
RUNTIME_CONTEXT_RUN_ID_KEY
- See Also:
-
RUNTIME_CONTEXT_MESSAGES_KEY
- See Also:
-
RUNTIME_CONTEXT_TOOLS_KEY
- See Also:
-
RUNTIME_CONTEXT_CONTEXT_KEY
- See Also:
-
RUNTIME_CONTEXT_STATE_KEY
- See Also:
-
RUNTIME_CONTEXT_FORWARDED_PROPS_KEY
- See Also:
-
RUNTIME_CONTEXT_RESUME_KEY
- See Also:
-
RUNTIME_CONTEXT_RESUME_INTERRUPTS_KEY
- See Also:
-
-
Constructor Details
-
AguiAgentAdapter
Creates a new AguiAgentAdapter.- Parameters:
agent- The agent to adaptconfig- The adapter configuration
-
-
Method Details
-
run
Run the agent with AG-UI protocol input.This method converts the input messages, invokes the agent's streaming API, and emits AG-UI protocol events.
- Parameters:
input- The AG-UI run input- Returns:
- A Flux of AG-UI events
-
run
public reactor.core.publisher.Flux<AguiEvent> run(RunAgentInput input, io.agentscope.core.agent.RuntimeContext runtimeContext) Run the agent with AG-UI protocol input and caller-provided runtime context.The provided context is copied and enriched with AG-UI runtime metadata. AG-UI metadata and the session id are always derived from
inputso callers can add custom values without losing the protocol defaults.- Parameters:
input- The AG-UI run inputruntimeContext- Optional caller-provided runtime context- Returns:
- A Flux of AG-UI events
-
buildRuntimeContext
protected io.agentscope.core.agent.RuntimeContext buildRuntimeContext(RunAgentInput input, io.agentscope.core.agent.RuntimeContext runtimeContext) Build the runtime context used for the agent invocation.The caller-provided context is copied first, then AG-UI protocol metadata is applied so that required request values and session isolation are always preserved. A per-call tool request config is built from the frontend tools and carried via
RuntimeContext.getToolRequestConfig()so the shared toolkit is never mutated and concurrent runs on the same agent are isolated.- Parameters:
input- The AG-UI run inputruntimeContext- Optional caller-provided runtime context- Returns:
- The effective runtime context for this run
-