Class PlanModeMiddleware
- All Implemented Interfaces:
io.agentscope.core.middleware.MiddlewareBase,HarnessRuntimeMiddleware
AgentState.planModeContext.planActive is true, mutating
tool calls are denied so the agent can only read / investigate and draft a plan.
Enforcement is deterministic and happens in onActing(io.agentscope.core.agent.Agent, io.agentscope.core.agent.RuntimeContext, io.agentscope.core.middleware.ActingInput, java.util.function.Function<io.agentscope.core.middleware.ActingInput, reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>>): each tool call is allowed iff
it is read-only or one of the plan-control tools (plan_enter / plan_write /
plan_exit / todo_write); everything else gets a synthetic DENIED tool
result (written to context and streamed as events) without being executed. This intentionally
does not reuse PermissionMode.EXPLORE: that mode is snapshotted immutably by the
PermissionEngine at construction and cannot be toggled at runtime, whereas plan mode must
switch dynamically.
onSystemPrompt(io.agentscope.core.agent.Agent, io.agentscope.core.agent.RuntimeContext, java.lang.String) injects a plan-mode banner so the model knows it is in the read-only
design phase.
-
Constructor Summary
ConstructorsConstructorDescriptionPlanModeMiddleware(PlanModeManager manager, Predicate<String> readOnlyResolver) PlanModeMiddleware(PlanModeManager manager, Predicate<String> readOnlyResolver, Set<String> additionalAllowed) -
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) reactor.core.publisher.Mono<String>onSystemPrompt(io.agentscope.core.agent.Agent agent, io.agentscope.core.agent.RuntimeContext ctx, String currentPrompt) 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, order
-
Constructor Details
-
PlanModeMiddleware
- Parameters:
manager- shared plan-mode state/file coordinatorreadOnlyResolver- resolves whether a tool (by name) is read-only; used to decide which calls are permitted while plan mode is active
-
PlanModeMiddleware
public PlanModeMiddleware(PlanModeManager manager, Predicate<String> readOnlyResolver, Set<String> additionalAllowed) - Parameters:
manager- shared plan-mode state/file coordinatorreadOnlyResolver- resolves whether a tool (by name) is read-only; used to decide which calls are permitted while plan mode is activeadditionalAllowed- extra tool names that are permitted while plan mode is active even when not read-only (opt-in escape hatch — e.g.executefor shell-based investigation). The model is instructed via the plan banner to use them read-only only.
-
-
Method Details
-
onSystemPrompt
public reactor.core.publisher.Mono<String> onSystemPrompt(io.agentscope.core.agent.Agent agent, io.agentscope.core.agent.RuntimeContext ctx, String currentPrompt) - Specified by:
onSystemPromptin interfaceio.agentscope.core.middleware.MiddlewareBase
-
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
-