Class DynamicSubagentsMiddleware
java.lang.Object
io.agentscope.harness.agent.middleware.DynamicSubagentsMiddleware
- All Implemented Interfaces:
io.agentscope.core.middleware.MiddlewareBase,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):
- Layer 1 (override) —
filesystem.glob("*.md", "subagents")+ per-filefilesystem.read. The backend'sNamespaceFactoryis applied transparently so each user sees their own slice of the store. - Layer 2 (base) —
AgentSpecLoader.loadFromDirectoryreads the local workspacesubagents/directory directly. - 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 Summary
ConstructorsConstructorDescriptionDynamicSubagentsMiddleware(List<SubagentEntry> staticEntries, AbstractFilesystem filesystem, Path mainWorkspace, Function<SubagentDeclaration, SubagentFactory> factoryBuilder, DefaultAgentManager agentManager, Object subagentTool, TaskRepository taskRepository) -
Method Summary
Modifier and TypeMethodDescriptionReturns the internalDefaultAgentManagerthat can re-materialize subagents, ornullwhen none is owned.getTools()Returns the tool instances this middleware contributes to the agent toolkit.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) Wires a gateway bridge into the internalAgentSpawnTool, enabling spawned subagents to be exposed as user-addressable threads.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
onActing, onAgent, onModelCall, onSystemPrompt, order
-
Constructor Details
-
DynamicSubagentsMiddleware
public DynamicSubagentsMiddleware(List<SubagentEntry> staticEntries, AbstractFilesystem filesystem, Path mainWorkspace, Function<SubagentDeclaration, SubagentFactory> factoryBuilder, DefaultAgentManager agentManager, Object subagentTool, TaskRepository taskRepository)
-
-
Method Details
-
setGatewayBridge
Wires a gateway bridge into the internalAgentSpawnTool, enabling spawned subagents to be exposed as user-addressable threads. Only effective when the middleware owns aDefaultAgentManager. -
getAgentManager
Returns the internalDefaultAgentManagerthat can re-materialize subagents, ornullwhen none is owned. Used to wire a gateway materializer for cross-node exposed-subagent recovery. -
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
-
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:
onReasoningin interfaceio.agentscope.core.middleware.MiddlewareBase
-