Skip to content

feat: hold new goals created under a planning-only agent - #64

Merged
willytop8 merged 1 commit into
mainfrom
wr/plan-mode-hardening
Aug 29, 2026
Merged

feat: hold new goals created under a planning-only agent#64
willytop8 merged 1 commit into
mainfrom
wr/plan-mode-hardening

Conversation

@willytop8

Copy link
Copy Markdown
Owner

Problem

The idle guard added earlier pauses auto-continue when the active agent is Plan — but it only fires on the next idle.

So /goal <objective> while in Plan mode currently:

  1. creates a live goal, and
  2. sends the routed confirmation text as a work turn, including the line Start working toward this goal now.

Command text reaches the model as a normal turn on current OpenCode builds (documented under Limitations), so that line is an escape from the very guard the idle check provides. The model can begin work before any idle occurs.

Change

Hold such a goal instead of starting it:

  • recorded with the same plan agent active stop reason the idle path already uses, so /goal status reads identically either way
  • clock paused, so the budget survives the mode switch — nothing is lost
  • announced through a read-only control turn (startsWork: false) that explicitly tells the model not to begin work

/goal resume after switching to an executing agent starts the work.

Also generalizes the hardcoded Plan check into configuration:

Option Default Controls
restrictedAgents ["plan"] Agent names treated as planning-only (case-insensitive). [] releases the restriction.
allowGoalExecutionFromPlan false Allow creation and auto-continue while a restricted agent is active.

Compatibility

  • isPlanAgent is retained as the built-in case; the plan agent active stop reason string is unchanged, so persisted state and existing consumers are unaffected.
  • Default behavior for anyone not setting the new options changes only in that a goal created under Plan is now held rather than started.
  • The resume path is deliberately not changed: test/host-lifecycle.test.js encodes that resuming under Plan returns ok while the idle guard still blocks execution, and that property already holds.

Verification

npm run release:check → exit 0

  • 401 tests / 401 pass (394 on main before this change; +7 new)
  • mutation contract 68/68, including a new entry — hardcoding allowGoalExecutionFromPlan to true fails the suite
  • behavior benchmark score 100
  • type contract (NodeNext + Bundler), command hook smoke, packed host contract, packed tool contract (11 tools)
  • npm audit --omit=dev --audit-level=high → 0 vulnerabilities

The new tests were verified to actually catch the defect: removing the creation-time hold in a scratch copy fails 2 of them.

Not verified

Not exercised against a live OpenCode host — unit/contract level only. Worth a Plan-mode canary run before the next release.

🤖 Generated with Claude Code

The idle guard pauses auto-continue when the active agent is Plan, but it
only fires on the *next* idle. Setting a goal while in Plan mode therefore
created a live goal, and the routed command text still told the model
"Start working toward this goal now." — as a work turn. Command text
reaches the model as a normal turn on current OpenCode builds, so that
line was an escape from the very guard the idle check provides.

Hold such a goal instead: record it with the same `plan agent active`
stop reason the idle path uses, pause its clock so the budget survives
the mode switch, and announce it through a read-only control turn that
explicitly tells the model not to begin work.

Also generalize the hardcoded Plan check into `restrictedAgents`
(default `["plan"]`) with an `allowGoalExecutionFromPlan` opt-out, so a
deployment can restrict other planning-only agents or release the
restriction. `isPlanAgent` is kept as the built-in case and the existing
`plan agent active` stop reason is preserved, so persisted state and
existing consumers are unaffected.

Pinned by a new mutation-contract entry: hardcoding the opt-out to true
fails the suite.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@willytop8
willytop8 merged commit 8eda192 into main Aug 29, 2026
17 of 18 checks passed
@willytop8
willytop8 deleted the wr/plan-mode-hardening branch August 29, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant