Repository navigation
fix(ai): preserve Responses history after compaction - #120729
Conversation
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 6:45 PM ET / 22:45 UTC. ClawSweeper reviewWhat this changesThis PR preserves post-checkpoint tool results in OpenAI Responses requests and rebuilds a rejected compaction retry from the unmodified transcript. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open for maintainer review: the patch appears to repair the two replay failures through the shared owner, but direct OpenAI SDK and required Codex-source contract audits were unavailable. Likely related people: steipete, the original compaction-replay and follow-up author (high confidence). Priority: P1 Review scores
Verification
How this fits togetherThe Responses transport converts an agent transcript into OpenAI or Azure request input and carries the provider’s opaque compaction checkpoint across turns. Its retry path determines whether a rejected checkpoint falls back to the full conversation or an incomplete suffix. flowchart LR
A[Agent transcript] --> B[Replay planner]
B --> C[Checkpoint request]
B --> D[Full-history retry]
C --> E[OpenAI and Azure transports]
D --> E
E --> F[Provider response]
F --> G[Session transcript]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +48, Tests +201. Total +249 across 20 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the transport-owned replay plan, but complete direct OpenAI SDK and Codex contract review on the exact head before landing. Do we have a high-confidence way to reproduce the issue? Yes — source inspection shows the prior retry stripped compaction from an already-pruned request; the exact-head regressions exercise the full-history fallback and post-checkpoint tool-result path, though they were not executed in this read-only review. Is this the best way to solve the issue? Yes — centralizing checkpoint versus full-history selection in the replay owner is the narrowest maintainable repair; final dependency-contract confirmation remains required before merge. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cdaea2d6b67c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
ClawSweeper rank-up disposition for
No actionable ClawSweeper finding remains. The dependency-contract rank-up move is complete, and the maintainer considers this head ready for the guarded prepare/merge workflow. |
|
Land-ready verification for exact head
Known proof gap: the expensive paid live suites were not repeated for this narrowly focused correction; deterministic owner-boundary regressions, direct dependency audits, clean post-rebase autoreview, and exact-head required CI cover the change. |
What Problem This Solves
Fixes two confirmed failures from #120457 in long embedded Responses sessions. First, a
function_call_outputarriving after compaction was dropped when its matchingfunction_calllived inside the compacted prefix. Second, when a compaction checkpoint was rejected, the retry started from an already-pruned suffix, allowing a plausible but context-blind answer to be committed.Why This Change Was Made
The replay plan now keeps the raw transcript immutable before any projection or pruning. The normal request sends the compaction checkpoint plus its chronological suffix; rejection lazily builds a fallback from the untouched full history instead of reusing the pruned request. Within the narrow compaction window, unframed function results are preserved even when their calls moved into the compacted prefix, while the existing pairing policy remains in place outside that window.
The same replay plan is carried through the SDK, SSE, WebSocket, and Azure success boundaries. This changes no configuration, protocol, or storage schema.
Related: #120457
User Impact
Long embedded Responses sessions retain chronological tool outputs and recover rejected checkpoints with full conversation history instead of silently losing context.
Evidence
node scripts/run-vitest.mjs packages/ai/src/transports/openai-responses-compaction-replay.test.ts packages/ai/src/transports/openai-responses-prompt-observer.test.ts src/agents/transport-message-transform.test.ts— 3 files passed across 2 shards, 78 tests passed (31 + 47).node scripts/run-vitest.mjs packages/ai/src/providers/openai-chatgpt-responses.encrypted-retry.test.ts packages/ai/src/providers/openai-responses-shared.test.ts packages/ai/src/providers/azure-openai-responses.test.ts— 3 files passed in 1 shard, 95 tests passed.git diff --check origin/main...HEAD— passed.node_modules/.bin/oxfmt --check <all 20 touched files>— passed; all matched files use the correct format.