AsyncToolMiddleware
public class AsyncToolMiddleware implements HarnessRuntimeMiddleware
io/agentscope/harness/agent/middleware/AsyncToolMiddleware.java:65–295异步工具中间件,在智能体执行流程中提供横切扩展。位于 io.agentscope.harness.agent.middleware 包,实现 HarnessRuntimeMiddleware。核心成员包括 onActing、AsyncToolMiddleware。
Middleware that offloads long-running tool calls to background execution.
When the acting phase exceeds the configured timeout:
-
The underlying tool execution continues in the background (never cancelled)
-
A placeholder
ToolResultBlockis written to agent context so the LLM can continue reasoning -
When the background execution completes, the real result is pushed to the session's inbox as a
HintBlockand a wakeup is enqueued
The InboxMiddleware drains the inbox on the next reasoning step, making the
real result available to the LLM.
构造器摘要Constructor Summary
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Flux<AgentEvent> onActing(Agent agent, RuntimeContext ctx, ActingInput input, Function<ActingInput, Flux<AgentEvent>> next) | 处理执行事件。 Performs the on acting operation. |
构造器详情Constructor Detail
AsyncToolMiddleware
public AsyncToolMiddleware(MessageBus messageBus, Duration offloadTimeout)
初始化 AsyncToolMiddleware 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
messageBus | MessageBus | 消息总线(类型 `MessageBus`)。The message bus. |
offloadTimeout | Duration | 卸载超时(类型 `Duration`)。The offload timeout. |
io/agentscope/harness/agent/middleware/AsyncToolMiddleware.java:81–83AsyncToolMiddleware
public AsyncToolMiddleware(MessageBus messageBus, Duration offloadTimeout, AsyncToolRegistry asyncToolRegistry)
初始化 AsyncToolMiddleware 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
messageBus | MessageBus | 消息总线(类型 `MessageBus`)。The message bus. |
offloadTimeout | Duration | 卸载超时(类型 `Duration`)。The offload timeout. |
asyncToolRegistry | AsyncToolRegistry | 异步工具注册表(类型 `AsyncToolRegistry`)。The async tool registry. |
io/agentscope/harness/agent/middleware/AsyncToolMiddleware.java:85–90方法详情Method Detail
onActing
public Flux<AgentEvent> onActing(Agent agent, RuntimeContext ctx, ActingInput input, Function<ActingInput, Flux<AgentEvent>> next)
处理执行事件。
Performs the on acting operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agent | Agent | 智能体(类型 `Agent`)。The agent. |
ctx | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The ctx. |
input | ActingInput | 输入消息(类型 `ActingInput`)。The input. |
next | Function<ActingInput, Flux<AgentEvent>> | 下一个(类型 `Function >`)。The next. |
Flux<AgentEvent>io/agentscope/harness/agent/middleware/AsyncToolMiddleware.java:92–180