feat(feedback): add context anchoring instructions to plan denial#432
feat(feedback): add context anchoring instructions to plan denial#432aviadshiber 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>
|
Hey @aviadshiber , thanks for this PR and sorry for taking so long to get back to you. The context anchoring idea is great. We ended up going a different direction with the implementation though. Instead of hardcoding the context anchoring into the denial template, we built a configurable feedback pipeline that lets users customize all plan/annotation/review messages via The new docs page walks through how to set it up: users drop your exact denial + approval templates into their config and they're done. You're credited by name with a link to your GitHub profile as the contributor behind the example. We're going to close this PR, but you will get co-author credit on the commit that ships the feedback pipeline. Thanks again for the contribution, it directly shaped how we documented and designed the customization system. |
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