fix(agents): dedupe transcript rewrite replay#79150
Conversation
|
Codex review: needs changes before merge. Summary Reproducibility: yes. The linked issue provides persisted JSONL/log evidence, and current-main source tracing shows overflow recovery reaches unguarded suffix replay; I did not run a live overflow in this read-only review. Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Land a current-base transcript rewrite idempotency fix that dedupes replay clones while preserving distinct compaction kept-entry boundaries, then close the concrete Track A issue and leave the broader umbrella open. Do we have a high-confidence way to reproduce the issue? Yes. The linked issue provides persisted JSONL/log evidence, and current-main source tracing shows overflow recovery reaches unguarded suffix replay; I did not run a live overflow in this read-only review. Is this the best way to solve the issue? No, not as written. The central rewrite replay boundary is the right place to fix this, but compaction identity should include the remapped firstKeptEntryId so distinct compaction boundaries are not collapsed. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against ea16a5e9e10c. |
Summary
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Real behavior proof (required for external PRs)
External contributors must show after-fix evidence from a real OpenClaw setup. Unit tests, mocks, lint, typechecks, snapshots, and CI are supplemental only. Screenshots are encouraged even for CLI, console, text, or log changes; terminal screenshots and copied live output count. Be mindful of private information like IP addresses, API keys, phone numbers, non-public endpoints, or other private details when providing evidence.
pnpm exec tsx, branch based onupstream/mainata1ac559ed7.SessionManagerJSONL file, appends three identical user payloads plus two duplicateopenclaw:bootstrap-context:fullcustom entries, calls the productionrewriteTranscriptEntriesInSessionFile(...)function, reopens the session file, and prints the active branch counts.before user_count=3andbefore bootstrap_count=2immediately before invoking the rewrite path.Root Cause (if applicable)
For bug fixes or regressions, explain why this happened, not just what changed. Otherwise write
N/A. If the cause is unclear, writeUnknown.rewriteTranscriptEntriesInSessionManagerandrewriteTranscriptEntriesInStatebranched from the first replaced message and then appended every suffix entry without an idempotency invariant.Regression Test Plan (if applicable)
For bug fixes or regressions, name the smallest reliable test coverage that should catch this. Otherwise write
N/A.src/agents/pi-embedded-runner/transcript-rewrite.test.tsUser-visible / Behavior Changes
Overflow-recovery transcript rewrites should stop amplifying exact replayed transcript records in session JSONL. Normal repeated user text with distinct message timestamps remains preserved.
Diagram (if applicable)
Security Impact (required)
Yes/No) NoYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation: N/ARepro + Verification
Environment
pnpmwrappersSteps
AgentMessagepayload.rewriteTranscriptEntriesInSessionManagerandrewriteTranscriptEntriesInSessionFile.Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations
AgentMessagepayload, so repeated same text with different timestamps remains a distinct turn; a regression test locks this in.