Class DynamicSubagentsMiddleware

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

public class DynamicSubagentsMiddleware extends Object implements HarnessRuntimeMiddleware
Dynamic counterpart to SubagentsMiddleware that re-resolves the registered subagent set on every reasoning step, supporting per-user isolation through the workspace AbstractFilesystem (e.g. CompositeFilesystem routing user-scoped writes into a remote Store).

Two-layer load (mirrors the previous DynamicSubagentsHook override semantics):

  1. Layer 1 (override) — filesystem.glob("*.md", "subagents") + per-file filesystem.read. The backend's NamespaceFactory is applied transparently so each user sees their own slice of the store.
  2. Layer 2 (base) — AgentSpecLoader.loadFromDirectory reads the local workspace subagents/ directory directly.
  3. Merge — same-name entries from Layer 1 override Layer 2; programmatic (builder-registered) entries are preserved as the static prefix and same-name dynamic declarations override them too.
  • Constructor Details

  • Method Details

    • setGatewayBridge

      public DynamicSubagentsMiddleware setGatewayBridge(SubagentGatewayBridge bridge)
      Wires a gateway bridge into the internal AgentSpawnTool, enabling spawned subagents to be exposed as user-addressable threads. Only effective when the middleware owns a DefaultAgentManager.
    • getAgentManager

      public DefaultAgentManager getAgentManager()
      Returns the internal DefaultAgentManager that can re-materialize subagents, or null when none is owned. Used to wire a gateway materializer for cross-node exposed-subagent recovery.
    • getTools

      public List<Object> getTools()
      Returns the tool instances this middleware contributes to the agent toolkit. The caller is responsible for registering them on the toolkit at orchestration time.
    • getTaskRepository

      public TaskRepository getTaskRepository()
    • onReasoning

      public reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> onReasoning(io.agentscope.core.agent.Agent agent, io.agentscope.core.agent.RuntimeContext ctx, io.agentscope.core.middleware.ReasoningInput input, Function<io.agentscope.core.middleware.ReasoningInput,reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>> next)
      Specified by:
      onReasoning in interface io.agentscope.core.middleware.MiddlewareBase