Repository navigation
fix(agents): preserve pending reply delivery custody - #170937
Conversation
Keep unresolved source delivery separate from missing delivery when selecting replacement answers, attachments, and errors. Preserve committed mirrors and recovery for later steered inputs with missing delivery. Corrects the pending-custody case from #170916.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cdaa942cd2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (sourceReplyDeliveryState === "pending") { | ||
| return; |
There was a problem hiding this comment.
Pass observed custody into payload selection
When resolveReplyDelivery reports pending or throws, settled-turn-finalization.ts passes that fact as replyDeliveryState, but terminal-preparation.ts:192-226 never forwards input.replyDeliveryState to buildEmbeddedRunPayloads; its spread supplies only the attempt's normally missing state. This guard and the warning guard are therefore bypassed in the real embedded-agent terminal path, leaving replacement answer, attachment, or error payloads that outer dispatch can deliver even though the result is marked pending. Pass the effective observed state into the payload builder and cover this production composition.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 657c28e. Terminal preparation now reconciles attempt and observed delivery through the existing resolver and passes that state to payload construction, receipts, media merging, timeout recovery, and the prepared result. Actual settled-finalization-to-terminal-resolution regressions reproduced the discarded observation for text, errors, media, and timeout recovery; heartbeat bypasses are covered too. The complete patch passes independent P2 review and 261 focused tests. Fresh CI is running for this head; the earlier green run is not used for this correction.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 657c28e23f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const payloadsWithToolMedia = | ||
| replyDeliveryState === "pending" | ||
| ? payloads |
There was a problem hiding this comment.
Preserve earlier-input media while current delivery is pending
When a steered run has undelivered tool media from an earlier input and the current input's delivery observation is pending, this branch returns the attempt's preceding-input payloads without calling mergeToolMedia. pendingToolMediaUrls is not cleared when a new user message seals an answer segment, so attempt.toolMediaUrls can still belong to the earlier payload that remains deliverable; the result then contains that earlier text but silently drops its attachment. Scope the pending suppression to current-input media rather than bypassing the attempt-wide merge.
AGENTS.md reference: src/agents/AGENTS.md:L28-L31
Useful? React with 👍 / 👎.
|
Merged via squash.
|
* fix(agents): preserve pending reply delivery custody Keep unresolved source delivery separate from missing delivery when selecting replacement answers, attachments, and errors. Preserve committed mirrors and recovery for later steered inputs with missing delivery. Corrects the pending-custody case from openclaw#170916. * fix(agents): propagate observed delivery custody through terminal preparation
What Problem This Solves
Fixes duplicate replacement replies when the original source reply may already have been sent but delivery is still pending. This is a corrective follow-up to #170916.
User Impact
Pending delivery now holds replacement text, attachments, errors, heartbeat responses, and timeout-recovered answers until the outcome is known. Already committed reply mirrors, their owned attachments, and answers for preceding inputs remain available. Confirmed missing delivery still produces the appropriate answer or error. No configuration or migration is required.
Why This Change Was Made
Delivery has three states: delivered, pending, and missing. The payload owner previously treated pending like missing. In addition, terminal preparation discarded the delivery observation supplied by settled-turn finalization, allowing its payloads to disagree with the terminal result's state.
Terminal preparation now reconciles attempt and observed delivery through the existing resolver once and carries that fact into payload selection, receipts, media merging, timeout recovery, and the returned prepared result. The per-input payload owner retains pending custody without falsely marking it delivered. Heartbeat response selection follows the same state. Current and carried terminal media is held without consuming the carry, so a later missing observation can release it.
Evidence
Negative tests reproduced duplicate text/media, provider errors, tool warnings, remote attachment reads, heartbeat replies, and timeout recovery. Actual settled-turn finalization through terminal resolution reproduced nine ordinary-path failures and seven heartbeat-path failures before their fixes, while missing-delivery controls continued to pass. The regressions preserve earlier-input answers and committed tool-authored media and verify delivered-state precedence.
261 distinct focused tests across eight files pass, including 27 actual terminal-composition cases and finalizer admission/re-observation controls. Core and owning test typechecks, scoped lint, formatting, and independent complete-patch review through P2 pass. Final focused groups took 125.621 and 88.303 seconds including worker compilation; the affected finalizer controls took 23.654 seconds. Fresh exact-head GitHub CI is pending; previous-head CI is not treated as proof of this expanded correction. These tests exercise real production composition with deterministic fixtures; they do not claim a real external channel send. This changes backend reply selection, with no UI layout change.