Skip to content

fix(context): ledger receipts preserve the tool's conclusion (head+tail) - #32

Merged
ayman3000 merged 1 commit into
mainfrom
fix/receipt-conclusion
Jul 28, 2026
Merged

fix(context): ledger receipts preserve the tool's conclusion (head+tail)#32
ayman3000 merged 1 commit into
mainfrom
fix/receipt-conclusion

Conversation

@ayman3000

Copy link
Copy Markdown
Owner

Problem (reported from real use)

An agent wrote a script, ran it and got a traceback, then later said "I don't see evidence it was actually executed" and re-ran from scratch — it forgot the outcome of its own tool call.

Root cause: a ContextSift ledger receipt summarized a tool result with result.prefix(summaryLength) — the first 200 chars. For a failure that's "Traceback (most recent call last): File …"; the actual error is at the END (UnicodeEncodeError: …) and was discarded. Once the raw output was compacted into the ledger, the receipt conveyed no usable conclusion.

Fix

The receipt summary now keeps a head AND a tail (default length 200 → 320). So the conclusion — a shell exit line, a written path, or the exception at the bottom of a traceback — survives compaction, and the agent still knows what happened after its tool output is evicted.

Tests

  • New testReceiptSummaryCapturesConclusionAtTail: a failure's exception text (at the tail) appears in the ledger receipt (marked ERROR), along with the head.
  • Tightened two existing tests to assert the raw output isn't kept inline (a conclusion snippet in the ledger is now expected/desired). All 127 tests pass.

Credit: diagnosed from a live Naseem session.

A ContextSift receipt summarized a tool result with its first N chars, so a
failure captured the START of a traceback and dropped the ACTUAL error at the
end. Once the exchange was compacted into the ledger, the agent could no
longer tell whether the tool ran or why it failed — it would forget the
outcome of its own tool call and re-run from scratch.

The summary now keeps a head AND a tail (default length 200 -> 320), so the
conclusion — a shell exit line, a written path, or the exception at the
bottom of a traceback — survives compaction.

Regression: a failure's exception text (at the tail) appears in the ledger
receipt; existing externalization/recency tests tightened to check the raw
output isn't kept INLINE (a conclusion snippet in the ledger is expected).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@ayman3000
ayman3000 merged commit e72ef85 into main Jul 28, 2026
1 check passed
@ayman3000
ayman3000 deleted the fix/receipt-conclusion branch July 28, 2026 11:37
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