Repository navigation
fix(agent-mode): preserve retained tool results across transcript commits - #1450
Merged
Merged
Conversation
baron
marked this pull request as ready for review
October 23, 2026 09:07
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.
Fixes #1326
Root cause
Completed tool cards retain full raw results in a session-owned, in-memory map after their source rows become sanitized summaries. Rebuilding that map from the summary rows loses the full result.
The original save-time repair and retention-reconciliation setters did that rebuild. Adversarial review also identified earlier in-place commits:
mutateItemsBatchat assistant/reasoning tool boundaries and terminal finalization, plus Codex command-status reconciliation. Those could discard the payload before save ever ran.Fix
commitSourceItems: unchanged rows keep their payloads/revisions; changed or new rows are re-inspected under the existing policy before notifying consumers.Dictionary(_:uniquingKeysWith:)defensively rather than trapping on a broken uniqueness invariant.No unbounded retention or persistence-format change is introduced. Raw payloads remain memory-only; reload behavior is unchanged.
Regression evidence and validation
make dev-test FILTER='AgentRetentionCompactionTests/testAssistantToolBoundary|AgentRetentionCompactionTests/testTerminalCommitBarrier|AgentRetentionCompactionTests/testSilentRepairReasons'— all 3 tests failed only on lost payloads/revisions (10 failures). The terminal test runs the real commit barrier and verifies its ownership, terminal revision, streaming finalization, and pending-tool repair.make dev-test FILTER='AgentRetentionCompactionTests|AgentToolCorrelationIndexTests|AgentSessionLinkLocalInputTests'— 46 tests passed: 11 retention, 3 tool-correlation, and 32 local-input tests. Includes changed-running-result refresh, removed-row pruning, silent repair reasons, mid-run/terminal preservation, both save branches, duplicate ownership, and ordinary replacement behavior.make dev-swift-build PRODUCT=RepoPrompt— passed.make dev-lint— passed.preflight.sh commitandpreflight.sh pushsafety gates — passed.Not run: full root suite / PR-ready lane, provider suite, release packaging, live CE MCP/UI smoke, or real-provider timing. No visible app was launched or stopped. Hosted checks are not claimed as complete.