Class PlanModeManager

java.lang.Object
io.agentscope.harness.agent.workspace.plan.PlanModeManager

public final class PlanModeManager extends Object
Coordinates plan mode for a single agent.

State (whether plan mode is active and which markdown file holds the current plan) lives in PlanModeContextState inside the agent's AgentState, so it is persisted with the session and survives restarts / cross-node hand-offs — this is the mechanism that makes dynamic (runtime) plan-mode switching work in a distributed setting, where an in-process boolean would be lost.

The plan markdown file is written exclusively through WorkspaceManager, never via java.nio.file.Files, so it lands on whatever backend (local, sandbox, remote) the agent's filesystem is configured with. The logical path stays <planDir>/PLAN.md for every isolation scope; per-scope isolation is applied transparently by the filesystem (store namespace for remote, snapshot key for sandbox) rather than by encoding it into the path.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Default workspace-relative directory for plan files.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PlanModeManager(WorkspaceManager workspaceManager, String planDir)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    enter(io.agentscope.core.state.AgentState state)
    Enters plan mode.
    void
    exit(io.agentscope.core.state.AgentState state)
    Exits plan mode (back to BUILD).
    boolean
    isPlanActive(io.agentscope.core.state.AgentState state)
     
    planFilePath(io.agentscope.core.state.AgentState state)
    Workspace-relative path of the plan file currently associated with this agent.
    writePlan(io.agentscope.core.agent.RuntimeContext rc, io.agentscope.core.state.AgentState state, String content)
    Writes (creates or overwrites) the plan markdown file through the workspace filesystem and records its path in state.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_PLAN_DIR

      public static final String DEFAULT_PLAN_DIR
      Default workspace-relative directory for plan files.
      See Also:
  • Constructor Details

  • Method Details

    • isPlanActive

      public boolean isPlanActive(io.agentscope.core.state.AgentState state)
    • enter

      public String enter(io.agentscope.core.state.AgentState state)
      Enters plan mode. Idempotent. Ensures a plan file path is recorded (default if none set).
      Returns:
      the workspace-relative plan file path
    • exit

      public void exit(io.agentscope.core.state.AgentState state)
      Exits plan mode (back to BUILD). Idempotent. Keeps currentPlanFile for reference.
    • planFilePath

      public String planFilePath(io.agentscope.core.state.AgentState state)
      Workspace-relative path of the plan file currently associated with this agent.
    • writePlan

      public String writePlan(io.agentscope.core.agent.RuntimeContext rc, io.agentscope.core.state.AgentState state, String content)
      Writes (creates or overwrites) the plan markdown file through the workspace filesystem and records its path in state.
      Returns:
      the workspace-relative path written