feat(feedback): add context anchoring instructions to plan denial#432
Open
aviadshiber wants to merge 4 commits intobacknotprop:mainfrom
Open
feat(feedback): add context anchoring instructions to plan denial#432aviadshiber wants to merge 4 commits intobacknotprop:mainfrom
aviadshiber wants to merge 4 commits intobacknotprop:mainfrom
Conversation
When a plan is denied, instruct the agent to maintain a `## Decisions Log` section in the plan tracking rejected approaches and their reasons. This implements the context anchoring pattern from Martin Fowler's article: the plan itself becomes the persistent ADR, visible in diffs and archived with every decision — at zero infrastructure cost. Closes backnotprop#431 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds planApproveFeedback() to shared feedback templates and uses it in the OpenCode plugin approval paths. On approval, the agent is reminded to reference the Decisions Log (built up during denial iterations) during implementation — completing the context anchoring loop for both deny and approve flows. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests that planDenyFeedback includes Decisions Log instructions and planApproveFeedback includes the Decisions Log reminder — for both plain approval and approval-with-notes paths. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- planApproveFeedback: header now reads "Plan approved with notes!" when notes are present, so the agent knows content follows - Extract DECISIONS_LOG_NOTE as a named export so Pi (and other integrations with custom approval messages) can append it without duplicating the string - Pi approval paths now include DECISIONS_LOG_NOTE in both the with-notes and plain-approval messages - planDenyFeedback: soften "Do NOT re-propose" to "Once added, do NOT re-propose" — accurate on first denial when the log doesn't exist yet - Add tests: "with notes" header, "without notes" header, DECISIONS_LOG_NOTE export Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the context anchoring pattern from Martin Fowler's article on context anchoring, applied to both the plan denial and approval flows.
The problem: when an agent gets a plan denied and revises, it only receives the current round's feedback — not what was rejected in prior rounds. It can re-propose the same approaches without knowing they were already rejected, creating iteration loops. And on approval, nothing reminds the agent to carry forward the decision history into implementation.
Changes
packages/shared/feedback-templates.tsplanDenyFeedback()— adds a## Context Anchoringsection instructing the agent to maintain a## Decisions Login the plan itself:planApproveFeedback()— new function used on plan approval, reminding the agent to reference the Decisions Log during implementation:apps/opencode-plugin/index.tsUses
planApproveFeedback()for both approval paths (with notes and without), replacing the previous inline strings.packages/shared/feedback-templates.test.tsAdds 4 tests covering the context anchoring behavior (all passing):
Decisions Loginstructions,Rejected:entry format, and cross-session memory noteDecisions LogreminderDecisions LogreminderWhy this approach
The plan is already the persistent artifact (saved to version history on every submission). By embedding rejected alternatives and their reasoning directly in the plan markdown, the ADR pattern works at zero infrastructure cost. The Decisions Log:
Test plan
## Decisions Logwith rejected approachesPart of #431
🤖 Generated with Claude Code