fix(agents): drop stale internal orphan prompts#96533
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Codex review: needs real behavior proof before merge. Reviewed July 6, 2026, 9:32 PM ET / 01:32 UTC. Summary PR surface: Source +22, Tests +94. Total +116 across 5 files. Reproducibility: yes. at source level: current main prepends non-duplicate orphan user text before the fresh prompt, and the linked issue supplies sanitized logs from that repair path. I did not establish a live current-main channel reproduction in this read-only review. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Pick one canonical embedded-runner/session repair for #76888, require real runtime proof for this branch if it remains the candidate, and then close or supersede the other overlapping PR after a maintainer-selected fix lands. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main prepends non-duplicate orphan user text before the fresh prompt, and the linked issue supplies sanitized logs from that repair path. I did not establish a live current-main channel reproduction in this read-only review. Is this the best way to solve the issue? Unclear as the final landing strategy: the helper boundary is plausible for this narrow stale-internal orphan shape, but #90759 overlaps the same canonical issue with broader session-repair semantics and stronger proof. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 349d3547ccd1. Label changesLabel justifications:
Evidence reviewedPR surface: Source +22, Tests +94. Total +116 across 5 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (3 earlier review cycles) |
|
I fixed the test-type blocker from the previous review and the PR head is now CI-clean ( I do not have access to a live OpenClaw session setup that can reproduce #76888 end to end. For the remaining proof gate, could someone with a real embedded-agent session validate these two cases?
|
|
@outdog-hwh thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward. Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive. Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it. |
|
This pull request has been automatically marked as stale due to inactivity. |
What Problem This Solves
Fixes #76888.
When transcript repair found a trailing orphaned user message from an internal inter-session event, it could prepend that stale content to the next fresh user prompt. For events like subagent announcements or completion markers, that meant the model could answer stale internal text instead of the user's current message.
Why This Change Was Made
The repair path already needed to preserve user-directed queued messages, including
sessions_sendinter-session input. The bug was that internal session-state events used the same orphaned-user leaf shape, so the merge step treated them as user content.This change classifies provenance before merging:
User Impact
Users should no longer get a response to stale internal transcript content after a queued/orphaned user-message repair. Legitimate queued user messages remain preserved, so no user-authored follow-up is lost.
Evidence
Local validation on the PR branch:
node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/attempt.test.ts src/agents/embedded-agent-runner/run/transcript-repair-runtime-contract.test.tspassed, 126 tests.node scripts/run-vitest.mjs src/sessions/input-provenance.test.tspassed, 19 tests.node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/message-merge-strategy.test.tspassed, 2 tests.node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/attempt.test.ts src/agents/embedded-agent-runner/run/transcript-repair-runtime-contract.test.ts src/agents/embedded-agent-runner/run/message-merge-strategy.test.ts src/sessions/input-provenance.test.tspassed, 147 tests.pnpm tsgo:core:testpassed.pnpm check:test-typespassed.node_modules\.bin\oxfmt.cmd --check --threads=1 src/agents/embedded-agent-runner/run/attempt.prompt-helpers.ts src/agents/embedded-agent-runner/run/attempt.test.ts src/agents/embedded-agent-runner/run/attempt.ts src/agents/embedded-agent-runner/run/message-merge-strategy.ts src/agents/embedded-agent-runner/run/transcript-repair-runtime-contract.test.tspassed.node_modules\.bin\oxfmt.cmd --check --threads=1 src/agents/embedded-agent-runner/run/transcript-repair-runtime-contract.test.tspassed after the test type follow-up.git diff --checkpassed.CI on PR head
e684ac2cb8b0bac7189459a75daf5b0ef0487dfcis green, includingcheck-test-types,check-prod-types,check-lint,check-guards,build-artifacts,QA Smoke CI, andReal behavior proof.Regression proof:
Before the production fix, the new stale-internal-leaf tests failed because the repaired prompt included
NO_REPLY stale subagent completionbefore the fresh inbound message. After the fix, those tests pass while the user-directedsessions_sendcase is still preserved.Maintainer validation requested:
I do not have access to a live OpenClaw session setup that can reproduce #76888 end to end. To complete the remaining proof gate, please validate in a real embedded-agent session that:
provenance.kind=inter_sessionandsourceTool=subagent_announceis removed and does not prepend staleNO_REPLY/completion text before the fresh prompt;sourceTool=sessions_sendis still preserved in the repaired prompt.Duplicate check:
Before opening this PR I rechecked open PRs/issues for
#76888, stale inter-session/orphan prompt wording, and the touched merge helpers. The prior direct attempts (#78094 and #90759) were closed unmerged, and I did not find an active PR covering this exact root cause.