Class AsyncToolMiddleware

java.lang.Object
io.agentscope.harness.agent.middleware.AsyncToolMiddleware
All Implemented Interfaces:
io.agentscope.core.middleware.MiddlewareBase, HarnessRuntimeMiddleware

public class AsyncToolMiddleware extends Object implements HarnessRuntimeMiddleware
Middleware that offloads long-running tool calls to background execution.

When the acting phase exceeds the configured timeout:

  1. The underlying tool execution continues in the background (never cancelled)
  2. A placeholder ToolResultBlock is written to agent context so the LLM can continue reasoning
  3. When the background execution completes, the real result is pushed to the session's inbox as a HintBlock and a wakeup is enqueued

The InboxMiddleware drains the inbox on the next reasoning step, making the real result available to the LLM.

  • Constructor Summary

    Constructors
    Constructor
    Description
    AsyncToolMiddleware(MessageBus messageBus, Duration offloadTimeout)
     
    AsyncToolMiddleware(MessageBus messageBus, Duration offloadTimeout, AsyncToolRegistry asyncToolRegistry)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.agentscope.core.middleware.MiddlewareBase

    onAgent, onModelCall, onReasoning, onSystemPrompt, order
  • Constructor Details

  • 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:
      onActing in interface io.agentscope.core.middleware.MiddlewareBase