[KongchangAI]
· 2 min read· 1,054 words

Making AI Coding Agents Remember Rejected Ideas: Lessons from an Open-Source Tool

Making AI Coding Agents Remember Rejected Ideas: Lessons from an Open-Source Tool

Developer builds cogit to record agent decision context, finding rejected options more worth preserving than decided ones.

The article describes how a developer running multiple Claude Code Agents across projects found that while code persists through version control, decision reasoning—especially rejected options—is lost when sessions end, causing new sessions to re-propose abandoned approaches. He built the open-source tool cogit, which uses Claude Code hooks to capture messages, generates summaries with a small model, and links back to message records in commit messages, prompting agents with a file's historical rejected options before editing. His key finding: rejected options are more valuable to record than decided ones, since decisions are already reflected in code but rejections aren't. cogit has two limitations: insufficient summary accuracy (6 of 20 spot-checked messages had errors) and overly narrow per-file prompting.

Running 5 to 10 Claude Code Agents simultaneously across multiple projects, the code survives between sessions—but the reasoning doesn't. Why a particular approach was chosen, what was rejected, what was tried first—all of it stays buried in chat logs no one will ever reopen. One developer kept running into new sessions that re-proposed already-rejected approaches, and couldn't even explain why the code looked the way it did. He built an open-source tool called cogit to address this, and shared the key findings from the process.

reddit source: My coding agents kept walking back into ideas we'd already rejected. What I learned trying to fix th

The Root Problem: Code Persists, Decision Context Doesn't

In multi-agent parallel development, the code itself persists through version control, but the reasoning behind each decision—especially the explicitly rejected options—isn't preserved by any mechanism. Newly launched agent sessions have no historical memory and can only re-reason from the current code state, making it easy for them to propose directions the team already discussed and abandoned.

The developer points out that it gets worse: when the code exhibits a particular structure, even he often can't explain why. Lost decision context doesn't just cause redundant work—it undermines people's understanding and control of the codebase.

How cogit Works: From Message Capture to Commit Linking

cogit's design is to record every message the developer sends to the agent, extract the decisions and rejected options from them, and link those to the resulting code commits. The mechanism has three parts:

  • Capture every message via Claude Code hooks;
  • Use a small model to generate a brief summary of each message;
  • Write a line into each commit message that points back to the corresponding message record.

In practice, before an agent edits a file, it receives a brief prompt listing the options previously rejected for that file. This way new sessions can avoid known dead ends before they start.

Claude Code hooks is the event hook mechanism provided by Anthropic's official CLI tool Claude Code. Developers can register commands in configuration files (such as .claude/settings.json) to trigger at specific lifecycle points—for example, when the user submits a message (user-prompt-submit), before/after tool calls (pre-tool-use/post-tool-use), and at session start or end. Hook scripts receive JSON input containing the current message, session ID, working directory, and other information, allowing external programs to execute custom logic before and after agent actions—this is exactly the foundation that lets cogit capture every message non-invasively and inject rejection prompts before file edits. Compared to modifying agent source code or relying on a specific API, hooks are a lightweight, general-purpose extension point.

Key Finding: Rejected Options Are More Valuable Than Decided Ones

The developer's most important insight: the most valuable information to bring back into a new session is what was rejected, not what was decided. The reason is straightforward—decisions are usually already reflected in the code; a glance at the code reveals which path was taken. But rejected options leave no trace in the code, and without deliberate recording, they vanish completely.

This observation has broad implications for the design of AI coding tools. Most current context-management solutions focus on preserving "what was done," but cogit's practice shows that "what wasn't done" is equally high-value information—and even harder to replace.

From an information-theory perspective, this finding can be understood as "negative space": the codebase is the positive space of decisions, showing only the paths ultimately adopted; rejected options form the negative space—they leave no trace in the code yet define the boundaries of the design space. The positive space can be reconstructed at low cost by reading the code; the negative space is extremely expensive to reconstruct, requiring backtracking through conversation history or relying on participants' memory. In AI agent scenarios, negative space is especially important: agents lack the oral tradition and organizational memory of human teams, and every session starts in an "amnesiac" state. Without explicitly persisting rejection records, they will repeatedly explore already-excluded territory, wasting compute and attention. This also explains why recording "what wasn't done" has higher marginal information value than recording "what was done."

Limitations and Candor: Summaries Can Be Wrong, Per-File Prompts Too Narrow

cogit is not a perfect solution. The developer himself disclosed two main problems.

Summary accuracy is insufficient. He spot-checked 20 messages, and 6 contained errors—with the rejected-options portion being the weakest link. His stance is therefore to treat these summaries as clues, not facts. This means the tool's output requires human judgment and cannot be blindly trusted.

Per-file prompts are too narrow in scope. The current mechanism only provides historical rejection prompts for a single file; related files don't receive the same prompts. For example, when editing file A, related rejection records from file B aren't surfaced. The developer openly admits this problem remains unsolved.

Open Questions for the Community

At the end of his share, the developer asks the community: how do you handle this problem in your own development environment? Do you feed past decisions into new sessions, or does every session start from scratch?

This question touches a core tension in AI coding agents: the context window is limited, while project history is infinite. cogit offers a lightweight engineering attempt—capture with hooks, compress with summaries, link with commits—but it also exposes two unsolved challenges: summary quality and scope control. For developers managing multiple agents simultaneously, finding the balance between "clean starts" and "carrying history" remains a direction worth continued exploration.

One-line Summary

A developer built cogit to record agent decision context and found that rejected options are more worth preserving than decided ones.

Paragraph Summary

The article describes how a developer running multiple Claude Code Agents across projects found that while code persists through version control, decision reasoning—especially rejected options—is lost when sessions end, causing new sessions to re-propose abandoned approaches. He built the open-source tool cogit, which uses Claude Code hooks to capture messages, generates summaries with a small model, and links back to message records in commit messages, prompting agents with a file's historical rejected options before editing. His key finding: rejected options are more valuable to record than decided ones, since decisions are already reflected in code but rejections aren't. cogit has two limitations: insufficient summary accuracy (6 of 20 spot-checked messages had errors) and overly narrow per-file prompting.

#AI coding agents#Claude Code#cogit#context management#rejected options#hooks#decision reasoning#open-source tool
Share:

Related articles