Skip to content

feat: enforce native plan collaboration policy - #80

Closed
jefft72 wants to merge 5 commits into
plan/01-persistencefrom
plan/02-session
Closed

jefft72 wants to merge 5 commits into
plan/01-persistencefrom
plan/02-session

Conversation

@jefft72

@jefft72 jefft72 commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Teaches AgentSession to enter and leave plan mode safely, swap its tool registry while planning, and hand back a one-shot continuation when a plan is accepted.

Replaces #64, which could not build against main.

Reasoning

Plan mode changes what the agent is allowed to do, so the transition needs to be refused while work is in flight rather than applied optimistically.
A submitted plan also has to be resolved before the session can return to default mode, otherwise an accepted plan could be silently abandoned.

The accepted plan is handed back as an opaque, single-use continuation rather than a plain string.
That lets the session reject stale or replayed tokens and bypass command, template, and input transformation for a handoff it already trusts.

The canonical read-only tools exposed while planning are built-ins, so a caller that disables built-ins must not get them back through plan mode.
The session now carries that decision explicitly and leaves submit_plan as the only planning tool in that case.

Changes

  • Adds setCollaborationMode with idle, queue, and pending-plan guards, plus persisted mode transitions
  • Swaps the tool registry for a plan-scoped one while planning, keeping submit_plan intrinsic
  • Adds resolvePlan, pendingPlan, pendingPlanContinuation, and promptPlanContinuation with stale-token rejection
  • Adds builtinToolsDisabled so planning honours --no-tools builtin
  • Fixes a stray closing brace in setActiveToolsByName that prevented the file from parsing
  • Removes a dead call to the profile-only compaction instructions helper

Testing

  • npx vitest --run test/suite/agent-session-plan-mode.test.ts test/plan-mode-tools.test.ts test/compaction.test.ts
  • tsgo --noEmit reports zero errors
  • biome check . clean

Reserve runtime replacements and guard session mutations so overlapping operations cannot corrupt active session state.
Configure plan-aware tools and prompts while constraining collaboration behavior to the active session mode.
Persist submitted plan state and resume accepted plans through the normal prompt lifecycle.
- A stray closing brace in setActiveToolsByName stopped agent-session.ts from parsing, which masked every other error in the file
- The manual compaction path also called the profile-only _compactionInstructions helper and never read the result, so the dead assignment is dropped rather than reimplemented
- Plan mode rebuilt the canonical read-only tools from the built-in registry, so --no-tools builtin still exposed read, grep, find, and ls while planning
- The session now carries the built-in tool decision from the caller, leaving submit_plan as the only planning tool when built-ins are disabled
@Pepps233
Pepps233 self-requested a review August 16, 2026 18:49
@Pepps233 Pepps233 added enhancement New feature or request coding-agent labels Aug 16, 2026
@Pepps233
Pepps233 requested a review from Issacboy123 August 16, 2026 18:51

@Issacboy123 Issacboy123 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Cleanly puts plan lifecycle, persistence, and tool policy in the session layer. It also preserves a disabled built-in tool policy while plan mode is active, which avoids reopening access through the new mode. Didn't find any significant issues in review.

@Pepps233 Pepps233 closed this Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coding-agent enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants