Skip to content

fix(subagents): a child result committed to the requester transcript is never lost or replayed - #200249

Merged
obviyus merged 10 commits into
mainfrom
obviyus/results-as-state
Nov 17, 2026
Merged

obviyus merged 10 commits into
mainfrom
obviyus/results-as-state

Conversation

@obviyus

@obviyus obviyus commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What was wrong

A requester wake commits the child result to the parent transcript before it calls the model. If that turn then failed (for example the provider returned 529), the subagent row recorded delivery=failed, disposition=permanent_failure, next to its own requesterDelivery: consumed fact. The result was in the parent's transcript, but the row said it was lost.

  • Only private (completionTarget: "parent") completions counted a consumed input as delivered.
  • A yielded batch carries the yieldedFinalDeliverable marker (written on every yielded batch, subagent-registry-requester-yield.ts:580). It was excluded even when its turn failed before it answered, so it settled as a failure.
  • A result that never reached the transcript was given up after three attempts on a 30 s / 120 s ladder.

Measured on base 2435c1faa791 (real Gateway, real model, provider down for the parent model): delivery=failed disposition=permanent_failure consumed=true (table below).

The rule

  • A result committed to the requester transcript is never dispatched again.
  • If the turn failed before it answered, the result is delivered. This applies to yielded batches too. The turn's own error is visible in the chat, and the next turn reads the result from the transcript.
  • If the requester answered but its channel send failed, or the turn ended for a recorded policy reason, the outcome stays a failure, and its existing notice path still runs.
  • A result that no turn committed stays owed. It has no attempt limit, ladder or expiry, per the class rule "a failed turn does not touch a result; wake is a function of stored state".

What this deletes

  • The private-only and yielded-final exceptions in the consumed check. A committed input that is followed by a turn failure is delivered.
  • REQUESTER_SETTLE_WAKE_MAX_ATTEMPTS, the retry-delay ladder, resolveRequesterSettleRetryState and the exhaustion settle.

No storage, schema or protocol change, and no new module. Production code: +57 / −69 (−12). The additions are the turn-failed-before-answer rule (subagent-delivery-state.ts) and the missed-channel marker on the direct response.

What triggers a retry, and why it cannot spin

  • Only two things trigger the next attempt for an uncommitted result: the subagent sweeper tick (every 60 s, subagent-registry-sweeper.ts) and the Gateway restart restore.
  • A conflict that keeps happening cannot loop. The wake commits the input before it calls the model, so a later conflict only loses the answer. The result is then consumed, so it is delivered.
    • Probe: real Gateway, mock provider, a writer that appends to the parent transcript on every synthesis request, and the real sweeper ticked 6 times.
    • Result: 1 attempt in 6 ticks, row delivered, child input in the transcript once.
  • A down provider does not loop for the same reason. The requests counted below come from that one turn's own runner backoff.
  • Known limit: a failure before the commit (preparation or admission refused) is evaluated again once per sweeper tick. That attempt makes no model call. I did not change it.

E2E (real Gateway from source, claude-opus-5-5 parent and claude-sonnet-5-5 child via cliproxy; a local proxy returns 529 for the parent model while "down"; isolated state, service env stripped, unique random ports)

Journey Base 2435c1faa791 Head 10cfa70da2b2
Provider down 300 s while the yielded parent wakes for its child delivery=failed disposition=permanent_failure consumed=true. 7 refused requests, all within 62 s of the wake. delivery=delivered consumed=true while still down. 7 refused requests, all within 67 s of the wake, then 0 for the remaining ~4 min. No "couldn't be delivered".
Next human turn after the provider returns answers with the child result (it is in the transcript) answers parent-got child-final …
kill -9 the Gateway after the child ended and before the wake (parent busy) pending → after restart delivered consumed=true; the parent replies with the child result pending survives the kill → Gateway back in ~45 s → delivered consumed=true; the parent replies parent-got child-final … ~2 min after restart, once, with no duplicate

An intermediate head (39e5a58, production identical to ab9ab16) still showed failed/permanent_failure on the provider-down journey, the same as base. That run found the yielded-marker exception fixed in 10cfa70.

Tests: subagent-requester-delivery.test.ts adds yielded private finals ("failed before answering" → delivered, red before the fix; "missed its channel" → failed). server.subagent-transcript-conflict.test.ts now pins the new contract: a conflicted, uncommitted result stays owed and is due at once, and the 4th wake after 3 conflicts delivers it.

Local ClawSweeper review (gpt-6.1-sol, normal speed) of 10cfa70: patch is correct, 0 findings. Its maintainer question ("retry indefinitely without the attempt budget?") is answered by the class rule above: no attempts, ladders or expiry. The cost of retrying is bounded by the probe and the outage counts.

CI: the earlier red checks-node-changed-* jobs were [MISSING_EXPORT] resolveIdentityPathViaExistingAncestor from main (the same failure on #200247: https://github.com/openclaw/openclaw/actions/runs/43948463342/job/133585463142), fixed by #200242. The later red server.subagent-transcript-conflict.test.ts asserted the deleted ladder and was updated in 39e5a58.

Follow-ups (same class, separate PRs): /new before a pending result is consumed shows that result in the fresh conversation's runtime context; and "subagent source lifecycle changed before completion delivery" drops a finished result when the parent's run has moved on.

@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Nov 16, 2026
…ed, whatever the turn did next

A requester wake commits the child result to the parent transcript before
the model call. When that turn then failed (for example the provider was
overloaded), the row recorded delivery failed with permanent_failure while
its own requesterDelivery fact said consumed. Only private completions
treated a consumed input as delivered.

- Consumed means delivered for every completion. Delete the private and
  yielded-final exceptions.
- A result that never reached the transcript stays owed. Delete the
  three-attempt limit, the 30s/120s ladder and the exhaustion settle; the
  sweeper wakes the batch again.
- The wake no longer classifies a thrown dispatch error; it records the
  real reason on the pending batch.

Co-authored-by: obviyus <[email protected]>
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 16, 2026
@obviyus
obviyus force-pushed the obviyus/results-as-state branch from 327f1a4 to 6197818 Compare November 16, 2026 20:33
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 16, 2026
@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 61978184719014a684d68c72867296c5290de1c5, but the PR head is now 12e42654481649400adbef53b7525f9b97ad193c. Its old verdict and PR readiness labels are no longer current.

Next step
Comment @clawsweeper re-review when the current head is ready; pushes after the first review are not reviewed automatically.

Review history (1 earlier review cycle)
  • reviewed 2026-11-16T20:50:29.993Z sha 6197818 :: blocked before merge. :: [P2] Migrate the dispatch consumer tests to the new retry contract | [P3] Update the documented requester-settle delivery policy

Dispatch and consumption tests now assert the rule instead of the removed
attempt limit: unconsumed results stay owed across any number of failed
attempts, and a committed result is delivered once, even after a timeout,
Stop or cancelled continuation. The announce guide states the same rule.

Co-authored-by: obviyus <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M and removed size: S labels Nov 16, 2026
@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 16, 2026
… committed result is never replayed

A committed child result is delivered when the turn produced no answer, as
before. When the requester's answer exists but its channel send failed,
the outcome stays a failure with its existing notice path. Either way the
committed result settles once; it is never dispatched again.

Co-authored-by: obviyus <[email protected]>
@obviyus obviyus changed the title fix(subagents): a child result in the requester transcript is delivered, whatever the turn did next fix(subagents): a child result committed to the requester transcript is never lost or replayed Nov 16, 2026
obviyus and others added 6 commits November 17, 2026 03:50
…iled before answering

A turn that answered or ended for a recorded reason keeps its own outcome,
so message-tool and channel send failures keep their notice and suspension
paths. Private completions and yielded finals keep their existing rules,
and the cleanup check is unchanged. A committed input is still never
dispatched again.

Co-authored-by: obviyus <[email protected]>
A block carries no turn outcome, so it settles a committed input only by the
private rule, as before. Requester-batch tests now cover the real mutation
kernel: a committed public result is delivered when its turn failed before
answering, and stays failed when its answer missed the channel or the turn
ended for a recorded reason.

Co-authored-by: obviyus <[email protected]>
Only retryable refusals keep an uncommitted result owed. A permanent refusal,
such as a closed-turn transcript rejection, withholds it once with its error
and never dispatches it again, as before. The announce guide states both rules.

Co-authored-by: obviyus <[email protected]>
…rn itself failed

The real provider-outage outcome reached the wake through the direct path
with a requester turn-failure reason. Count those reasons as a turn that
failed before answering; outbound and recorded-policy reasons keep their
outcome.

Co-authored-by: obviyus <[email protected]>
…n miss its channel

A requester turn that failed (for example on a provider outage) can still
report a delivery failure. It has no answer, so its committed result is
delivered instead of kept as a missed send.

Co-authored-by: obviyus <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Nov 17, 2026
…delivered, not settled as failed

Co-authored-by: obviyus <[email protected]>
@obviyus
obviyus merged commit b601a4b into main Nov 17, 2026
185 of 187 checks passed
@obviyus
obviyus deleted the obviyus/results-as-state branch November 17, 2026 01:26
@obviyus

obviyus commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as b601a4b (head 10cfa70).

  • Bug: a child result committed to the parent transcript was recorded as failed/permanent_failure when the parent's turn then failed, for example on a provider 529. This covered public results and yielded batches.
  • Fix: a committed result is delivered if its turn failed before it answered. It is never dispatched again. A result that was not committed stays owed, with no attempt limit, ladder or expiry.
  • Proof: real Gateway with a real model, base 2435c1f vs head.
    • Provider down 300 s: base failed; head delivered consumed=true while still down. 7 refused requests in 67 s, then none.
    • kill -9 before the wake: delivered after restart.
    • A transcript conflict that hits every attempt: 1 attempt in 6 sweeper ticks.
  • Review and CI: the local ClawSweeper review of the exact head found the patch correct with 0 findings. CI is green; one runner timeout passed on rerun, and main is green.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 17, 2026
…is never lost or replayed (openclaw#200249)

A requester wake commits the child result to the parent transcript before it calls the model. If that turn then failed (for example a 529), the row recorded delivery=failed/permanent_failure next to its own consumed fact. This affected public results and yielded batches.

- A committed result is never dispatched again. If its turn failed before it answered, the result is delivered. A turn that answered but missed its channel keeps its failure.
- An uncommitted result stays owed, with no attempt limit, ladder or expiry.
- Deletes the private-only and yielded-final consumed exceptions, REQUESTER_SETTLE_WAKE_MAX_ATTEMPTS, the retry ladder, resolveRequesterSettleRetryState and the exhaustion settle.

Proof: real Gateway with a real model, base dd40e01 vs head 10cfa70. Provider down 300 s: base failed/permanent_failure, head delivered/consumed while still down, no loop. kill -9 before the wake: delivered after restart. A persistent transcript conflict produced 1 attempt in 6 sweeper ticks.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 19, 2026
…is never lost or replayed (#200249)

A requester wake commits the child result to the parent transcript before it calls the model. If that turn then failed (for example a 529), the row recorded delivery=failed/permanent_failure next to its own consumed fact. This affected public results and yielded batches.

- A committed result is never dispatched again. If its turn failed before it answered, the result is delivered. A turn that answered but missed its channel keeps its failure.
- An uncommitted result stays owed, with no attempt limit, ladder or expiry.
- Deletes the private-only and yielded-final consumed exceptions, REQUESTER_SETTLE_WAKE_MAX_ATTEMPTS, the retry ladder, resolveRequesterSettleRetryState and the exhaustion settle.

Proof: real Gateway with a real model, base 2435c1f vs head 10cfa70. Provider down 300 s: base failed/permanent_failure, head delivered/consumed while still down, no loop. kill -9 before the wake: delivered after restart. A persistent transcript conflict produced 1 attempt in 6 sweeper ticks.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit b601a4b)

Release adaptation: clean backport; consumed requester input is terminal without replay, while uncommitted transient failures remain owed.
Follow-up audit: no later named #200249 companion through pinned main.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 05d786e06f73efa3aca4b17c33f3074463f3e5d5)
tideclaw-bot pushed a commit that referenced this pull request Nov 20, 2026
Keep the synthetic provider on loopback despite inherited proxies. Align the post-revocation proof with #200249: a consumed child result remains delivered even when its requester stops before answering. Assert its structured transcript receipt and unchanged history rather than a false delivery-failure notice. Preserve provider cancellation timing, denied effects, Goal state, and revoked subscription checks.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit a1f3553c31ed3c16bf08befe04c831a2964a806d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant