Skip to content

Hypothesis ledger: record what each agent ruled out, and feed it to the next one (#303) - #337

Merged
currentbits merged 6 commits into
mainfrom
coder/hypothesis-ledger-show-what-each-agent-t-887a7e
Aug 17, 2026
Merged

currentbits merged 6 commits into
mainfrom
coder/hypothesis-ledger-show-what-each-agent-t-887a7e

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Closes #303.

Agents currently only report the approach that worked. What they ruled out is thrown away, so the next agent — or the next best-of-N fork — happily walks back into the same dead end. This adds a per-thread hypothesis ledger and, more importantly, feeds the ruled-out half of it back into the next dispatch.

How it works

Capture is agent-authored, never inferred. A new hypothesis_record tool on the existing coder-threads MCP server takes { threadId, projectId, claim, status: validated | invalidated | inconclusive, reason }, behind the same assertSameProject guard as thread_fork / thread_send. No transcript mining, no LLM pass, no scheduler. A sentence in the server INSTRUCTIONS tells agents to record each distinct approach as soon as they know how it turned out.

Storage rides the thread. ThreadInfo.hypotheses (contract in src/shared/ipc.ts), capped at 50 rows / 200-char claim / 500-char reason. recordHypothesis validates the status, trims and truncates, drops the oldest row past the cap, and writes without bumping updatedAt — a ledger entry is not sidebar activity, same rule as setNotes.

The ruled-out list reaches the next agent. hypothesisNoteFor joins planboardNoteFor / selfIdNoteFor as a standing note on every dispatched prompt, carrying the invalidated entries of the thread and up to five handoffFrom ancestors, deduped by claim and capped at 10 lines. Because it rides every turn rather than only the first, it survives context compaction and resumed sessions. It returns "" when there is nothing to say, so threads without a ledger dispatch exactly as they do today.

Surface. A read-only card on the Agents tab, ruled-out group first (that group is the point), then worked, then inconclusive — claim, reason and age per row. Rendered only when the thread has entries; a thread whose agents never recorded one looks unchanged. Grouping and the summary line live in a pure src/hypothesisLedger.ts so the component stays dumb and the logic is testable.

Verification

  • npm run test:electron 992/993 — the single failure is the web-integration reconnect test that already fails on main.
  • npm run test:renderer 831/831, npm run typecheck clean.
  • 19 new electron assertions in electron/test/hypotheses.test.js (caps, validation, same-millisecond id collisions, ancestor walk, handoffFrom cycle, cross-project rejection) plus test/hypothesisLedger.test.ts.
  • Dogfooded read-only against the live 304-thread store: no throws, no note emitted on any existing thread, and a fabricated entry on a real handoff parent does reach its worker's prompt.

Deliberately not built

  • Cross-sibling rollup for best-of-N: siblings start simultaneously, so one fork's dead end cannot reach the others in time. The ancestor walk covers the sequential case that actually matters; add the rollup when best-of-N gets a compare view to hang it on.

  • Any UI to edit or delete entries — the ledger is evidence, not a scratch pad.

  • runId on an entry: nothing exposes the active run id to the MCP handler, so grouping the card by run would have stored a null and pretended.

  • PR created by the Claude Code agent

Willem added 6 commits August 17, 2026 19:30
Read-only card grouped invalidated / validated / inconclusive, hidden when
the thread recorded none. Seeded on thread-1 for the browser demo.
)

Agent-written only. recordHypothesis stores on the thread without bumping
updatedAt; hypothesisNoteFor appends invalidated entries to the next
dispatch; hypothesis_record is the MCP write path.
…into coder/hypothesis-ledger-show-what-each-agent-t-887a7e
@currentbits
currentbits merged commit 351b3c0 into main Aug 17, 2026
1 check failed
@currentbits
currentbits deleted the coder/hypothesis-ledger-show-what-each-agent-t-887a7e branch October 3, 2026 16:07
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.

Hypothesis ledger: show what each agent tried and ruled out

1 participant