Skip to content

feat(memory): ambient nudges for record_decision and record_code_area#144

Open
rajkumarsakthivel wants to merge 6 commits into
mainfrom
feat/memory-nudges
Open

feat(memory): ambient nudges for record_decision and record_code_area#144
rajkumarsakthivel wants to merge 6 commits into
mainfrom
feat/memory-nudges

Conversation

@rajkumarsakthivel

Copy link
Copy Markdown
Member

Summary

CCE's cross-session memory depends on the agent calling record_decision and record_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_decision if a non-obvious choice was made. Includes "skip if this session is just exploration/reading" to prevent garbage recordings. After the first record_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_search or expand_chunk) without any record_code_area call. 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 already record_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):

[CCE] 4 context searches this session, 0 decision(s) recorded.
If you chose a library, resolved an ambiguity, or established a convention, call record_decision(decision="...", reason="...").
Skip if this session is just exploration/reading.

Example code area nudge:

[CCE] 3 files explored but not recorded: src/auth.py, src/middleware.py, src/routes.py
If you modified or traced a non-obvious flow, call record_code_area(file_path="...", description="...").
Skip for files you only glanced at.

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).
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