Repository navigation
refactor(ai): consolidate Responses replay paths - #123762
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 1:35 PM ET / 17:35 UTC. ClawSweeper reviewWhat this changesConsolidates OpenAI Responses replay conversion, Codex completion promises, and agent tool-result pairing behind shared helpers while removing duplicate code. Merge readinessKeep open. The refactor has no concrete source-level defect in the reviewed conversion, notification, or pairing changes, but direct Codex contract inspection and the prior requested behavior proof remain incomplete. Priority: P2 Review scores
Verification
How this fits togetherAgent session history is converted into OpenAI Responses input and replayed after compaction; Codex app-server notifications separately drive native turn completion. These paths affect whether a resumed session preserves its transcript and terminal state. flowchart LR
A[Session transcript] --> B[Replay conversion]
B --> C[Responses transport]
C --> D[Provider stream]
D --> E[Compaction replay]
F[Codex app-server events] --> G[Turn completion routing]
G --> E
Before merge
Agent review detailsSecurityNone. PR surfaceSource -334. Total -334 across 19 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land one canonical style-aware replay converter only after direct Codex contract review and a redacted after-fix replay trace confirm preserved transport and native-turn outcomes. Do we have a high-confidence way to reproduce the issue? Not applicable: this refactor is evaluated through behavioral equivalence and replay-path evidence rather than a reported user failure. Is this the best way to solve the issue? Unclear: the shared owner is the best structural direction from source review, but direct Codex contract evidence and the requested observed replay proof are still absent. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e03d1a42f808. LabelsLabel 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
HistoryReview history (1 earlier review cycle)
|
b2c2004 to
772f098
Compare
|
Merged via squash.
|
* refactor(ai): consolidate Responses replay ownership * refactor(codex): consolidate completion plumbing * refactor(agents): centralize replay pairing repair * refactor: preserve replay static contracts
What Problem This Solves
The compaction campaign added roughly 636 net production lines across #123397, #123485, #123486, #123622, #123640, and related work. Its deep review identified a concrete maintenance risk: OpenAI Responses replay conversion was implemented in parallel in the transport and provider paths, so later compaction, encrypted-reasoning, and full-history fixes had to remain synchronized by hand.
This PR recovers 334 production lines from that neighborhood without changing behavior or tests.
Why This Change Was Made
Responses message conversion and replay preparation now have one transport-owned implementation with explicit provider-versus-transport policy for the pre-existing semantic differences: transcript transforms, media projection, reasoning provenance, Copilot item IDs, tool argument serialization, and empty-message indexing. The encrypted-content retry state machine remains shared, while the SSE, WebSocket, and SDK dispatch loops stay separate because their retry and acceptance timing differ.
The same pass also consolidates exact Codex notification/deferred plumbing and the repeated model-specific tool-result pairing policy. The strict native-compaction watcher remains independent because it must discover the compaction turn, prove the matching compaction item completed, capture post-compaction usage, and hold its lifecycle fence through terminal confirmation.
User Impact
No user-visible behavior changes. This is a pure net-negative refactor that reduces drift risk across compaction replay paths while preserving all existing validation, fencing, retry timing, and provider-specific behavior.
Production LOC: +639/-973 (net -334) | Tests: +0/-0
Evidence
pnpm tsgo:prod, dependency dead-code, unused-file, and unused-export scans passed; the exact failed lint stripe is clean on rebasedmain.pnpm formatandgit diff --checkpassed.