feat(memory): ambient nudges for record_decision and record_code_area#144
Open
rajkumarsakthivel wants to merge 6 commits into
Open
feat(memory): ambient nudges for record_decision and record_code_area#144rajkumarsakthivel wants to merge 6 commits into
rajkumarsakthivel wants to merge 6 commits into
Conversation
Recording decisions and code areas currently depends on the agent obeying CLAUDE.md instructions. This makes memory opt-in and fragile. Agents that forget (or whose context compacts away the instructions) silently produce sessions with no durable memory. Two mechanisms make recording ambient: 1. Inline nudges on context_search results. After 4 searches with no record_decision, a directive appears listing the search count and prompting the agent to record if it made non-obvious choices. A separate nudge fires when 3+ files have been explored (via search or expand_chunk) without any record_code_area call, listing the specific unrecorded file paths. Both nudges include a "skip if" clause so the agent can ignore them when just browsing. After the first record_decision, the search threshold doubles to 8. 2. Stop hook summary. The Stop hook (already installed) now returns a compact session-end summary to stdout. The hook script is updated to capture Stop output (like SessionStart) so it gets injected into the agent's context. The summary lists search count, decisions recorded, and code areas recorded, with a directive to record if counts are low. New tests: 4 (decision nudge threshold, reset after record, code area nudge with unrecorded files, exclusion of recorded files).
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
CCE's cross-session memory depends on the agent calling
record_decisionandrecord_code_area, but that only happens when the agent obeys CLAUDE.md instructions. If context compacts or the agent just forgets, the session produces no durable memory. This PR makes recording ambient by nudging the agent from within tool results.Inline nudges on
context_search:Decision nudge fires after 4 context searches with 0 decisions recorded this session. Message includes the search count and a directive to call
record_decisionif a non-obvious choice was made. Includes "skip if this session is just exploration/reading" to prevent garbage recordings. After the firstrecord_decision, the threshold doubles to 8 (longer leash once the agent has shown it knows how).Code area nudge fires when 3+ files have been explored (via
context_searchorexpand_chunk) without anyrecord_code_areacall. Lists the specific unrecorded file paths (max 5) so the agent has concrete material to act on rather than a generic reminder. Files that were alreadyrecord_code_area'd are excluded from the count.Both nudges can fire in the same response. They appear before the output compression directive, as part of the tool result text.
Stop hook summary:
The existing Stop hook (fires on session end) now returns a compact summary: search count, decisions recorded, code areas recorded, with a directive to record if counts are low. The hook script is updated to capture Stop stdout (previously only SessionStart output was captured). Users get the updated script on next
cce init.Example nudge (after 4th search, 0 decisions):
Example code area nudge: