Class AsyncToolMiddleware
java.lang.Object
io.agentscope.harness.agent.middleware.AsyncToolMiddleware
- All Implemented Interfaces:
io.agentscope.core.middleware.MiddlewareBase,HarnessRuntimeMiddleware
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
ConstructorsConstructorDescriptionAsyncToolMiddleware(MessageBus messageBus, Duration offloadTimeout) AsyncToolMiddleware(MessageBus messageBus, Duration offloadTimeout, AsyncToolRegistry asyncToolRegistry) -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>onActing(io.agentscope.core.agent.Agent agent, io.agentscope.core.agent.RuntimeContext ctx, io.agentscope.core.middleware.ActingInput input, Function<io.agentscope.core.middleware.ActingInput, reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>> next) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.agentscope.core.middleware.MiddlewareBase
onAgent, onModelCall, onReasoning, onSystemPrompt, order
-
Constructor Details
-
AsyncToolMiddleware
-
AsyncToolMiddleware
public AsyncToolMiddleware(MessageBus messageBus, Duration offloadTimeout, AsyncToolRegistry asyncToolRegistry)
-
-
Method Details
-
onActing
public reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> onActing(io.agentscope.core.agent.Agent agent, io.agentscope.core.agent.RuntimeContext ctx, io.agentscope.core.middleware.ActingInput input, Function<io.agentscope.core.middleware.ActingInput, reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>> next) - Specified by:
onActingin interfaceio.agentscope.core.middleware.MiddlewareBase
-