[Bug]: Large-plan editing: full-plan resend per revision, one validation error per round-trip, no field paths
Environment: @prevalentware/opencode-goal-plugin 0.1.60 (installed bundle dist/server.js), OpenCode v2.0.29, Linux. Goal used for a long multi-phase task: 12 phases / 40 tasks, plan JSON 17.6 KB, 11 accepted plan revisions in one session.
Summary
Managing a large plan through update_goal_plan is workable at small sizes but becomes expensive and failure-prone as the plan grows:
- every revision must resend the entire plan (no diff/patch mode);
- every validation failure costs another full-plan resend, and cross-revision rules are enforced one violation at a time with no field paths;
- both
get_goaland the tool result echo the entire goal, so a routine status flip costs ≈3× plan size in tokens; - each auto-continue turn injects the full plan JSON into the prompt again.
Observed sequence — one logical edit (mark the last phase as blocked)
- Sent revision N with the phase set to
blocked(task-level blockers included, phase-levelblockeromitted) → rejected:{"error":{"type":"unknown","message":"[{\"code\":\"custom\",\"message\":\"blocked phases require a blocker\",\"path\":[\"plan\"]}]"}}(Zod custom issue anchored atpath: ["plan"], not at the offending phase). - Added the phase-level
blockerand resent the full plan → rejected again:changing planned phase scope requires concrete revisit evidence(plain throw, no path and no indication of what changed — in my case it was a cosmetic rewording of one phase's objective, which I could not identify from the message). - Added
revisit_evidenceand resent → accepted.
⇒ 3 round-trips / 3 full-plan sends for one status change, and the second error cannot be diagnosed without guessing (supplying revisit_evidence would also silently bless an unintended scope edit).
Also observed (possibly harness-side): a call missing a required field (reason) surfaced as Connection lost while reading the response: ECONNRESET instead of a validation error.
Cost numbers (measured from ~/.local/share/opencode-goal-plugin/goals.json)
- plan JSON: 17,625 chars ≈ 4.4k tokens; whole goal JSON: 30,732 chars ≈ 7.7k tokens
- 11 accepted revisions (
plan.changeslength) + 3 rejected attempts = 14 full-plan writes - each revision additionally follows the documented policy “Read get_goal and use its id and planRevision”, and the result echoes the whole goal → read + write + echo ≈ 20k tokens per revision (~0.3M tokens of bookkeeping for one goal on a 17.6 KB plan)
- every continuation prompt re-injects
JSON.stringify({plan, progress})in<untrusted_goal_plan>(~4.4k tokens per auto-continue)
Root causes (shipped dist/server.js)
planToolArgs(~line 2999): takesgoal_id,expected_revision,planin full (GoalPlanInputSchema),reason, optionalrevisit_evidence— no partial/diff input.reviseGoalPlan(~79–136): ten sequentialthrow new Error(...)statements (lines 81/86/92/94/98/100/102/108/112/114) — the first violation aborts, so one submission can be rejected repeatedly for different reasons.GoalPlanSchema(line 41):blocked phases require a blockeris a Zod custom issue atpath: ["plan"]; the cross-revision throws carry no path at all.planFromTool(~5010): returns{goal: <whole goal>};get_goalreturns the whole goal (plan + history + checkpoints).durablePlanContext(~1882): injects the full{plan, progress}JSON into every continuation prompt.
Suggested fixes (roughly in priority order)
- Aggregate violations: evaluate all cross-revision rules and throw one error listing every violation with a field path and the previous→next values, e.g.
phases[batch-f].objective changed ("F …(贯穿全程)" → "F …") — requires revisit_evidence. This cuts round-trips and prevents accidentally blessing scope changes. - Document the invariants in the model-facing tool description / per-field
.describe():completionCriteriaimmutable, blocked phases needblocker,revisit_evidencesemantics, completed task ID/description preservation. Today they are only discoverable by failing. - Patch/diff mode: accept
plan_ops(set phase status, upsert task, append decision) or a partial plan merged server-side; keep the full-plan mode as fallback so routine status flips stop resending the whole plan. - Compact reads/writes:
get_goalwith a summary mode returning{revision, progress, next_task}; return{revision, progress}rather than the whole goal fromupdate_goal_plan(behind a flag); inject onlyplanProgress+ revision into continuation prompts (the plan stays reachable viaget_goal) — also reduces pressure on the prompt-cache issue (#13). - Machine-readable errors: if the tool layer serializes validation issues anyway, make the plugin side emit a single multi-line human-readable message with paths so
{"error":{"type":"unknown","message":"…"}}stays readable.
Minimal reproduction
- create a goal with a 3-phase plan;
- set a phase to
blockedwithout a phase-levelblocker→ error 1 (path["plan"]); - add the blocker and reword any phase objective → error 2 (no path);
- add
revisit_evidence→ accepted.
⇒ 3 round-trips / 3 full-plan sends for one status change.
Happy to test a patch. The plan/phase/progress model itself is exactly what long-running sessions need — this is purely about the update API's cost and failure ergonomics.