Skip to content

fix: generated media completions retry for hours when the requester refuses the handoff - #199575

Merged
obviyus merged 2 commits into
mainfrom
openclaw/dawn-krill
Nov 15, 2026
Merged

obviyus merged 2 commits into
mainfrom
openclaw/dawn-krill

Conversation

@obviyus

@obviyus obviyus commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: a generated image or video completion retries every 1-2 seconds for hours after the requesting run has ended, when the Gateway refuses the completion handoff.

In production, two generated-image completion handoffs retried for 4.5 hours. Every attempt got the same INVALID_REQUEST refusal from the Gateway.

User Impact

User impact: a refused media completion stops after one attempt instead of retrying every 1-2 seconds until the Gateway restarts. Transient blocks such as a workspace that is not ready yet still retry.

Why This Change Was Made

  • Refusals are terminal. Completion delivery now treats a typed Gateway INVALID_REQUEST or FORBIDDEN refusal as a permanent failure. It reads the typed gatewayCode, not the message text. UNAVAILABLE, transport errors and the existing transient cases still retry.
  • Transient work-start blocks stay retryable. The agent handler returned some short-lived session states as non-retryable INVALID_REQUEST, for example "workspace is not ready" or "still initializing". These states already carry a retryable fact. The handler now sends that fact in the Gateway error, so completion delivery can tell a transient block from a refusal. Archived and other permanent blocks are unchanged.
  • Queued delivery stays under queue ownership. An earlier revision capped the queued wait at 10 minutes; review showed queued can legitimately outlast that, so the cap was dropped. Refusals ending after one attempt is what stops the incident.

Evidence

Focused tests (ocx test, vitest from source):

  • New: subagent-announce-delivery-retry.test.ts. A typed INVALID_REQUEST, alone or as a cause, is permanent. A retryable UNAVAILABLE is not.
  • Updated: the gateway agent handler test now checks that the pending-workspace refusal is retryable: true and the archived refusal is retryable: false. The direct-delivery test fixture for a pending workspace now uses that retryable shape and still expects retryable.
  • Passing (17 files, 6 shards): the src/agents/subagents/announce delivery and media tests, media-generate-review-delivery.test.ts, src/gateway/server-methods/agent.test.ts, and the gateway agent admission, session persist and session reuse tests.

Gates run locally: pnpm tsgo:core, pnpm check:test-types, pnpm check:test-mock-exports, pnpm check:max-lines-ratchet, pnpm check:line-cap-ratchet, pnpm check:assertion-safety, and oxlint plus format on the changed files.

Not run: the full build and the packed smoke. The change is limited to TypeScript runtime modules and tests, and it changes no build, packaging or public SDK surface. Hosted CI covers the full build. No live Gateway reproduction was run. The behavior is proven at the retry classifier and at the completion loop with fake timers.

@clawsweeper

clawsweeper Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling extensions: qa-lab size: XL labels Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Security-sensitive guard cleared

Current revision: a7ca4ac024db6d3046baa89a055c5002d6788480

This PR no longer changes files in the maintainer security-review tier.

Separate CODEOWNERS requirements still apply to security policy and enforcement files.

… waits

Treat typed Gateway INVALID_REQUEST and FORBIDDEN refusals as permanent
completion delivery failures. The agent handler now sends the existing
retryable fact for transient work-start blocks, so a pending workspace
still retries. Queue-owned media completions keep re-waking for the
follow-up turn, but stop 10 minutes after the first attempt and settle
as blocked with the media retained.

Co-authored-by: obviyus <[email protected]>
@obviyus
obviyus force-pushed the openclaw/dawn-krill branch from 94ade81 to da73f1d Compare November 15, 2026 11:26
@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added size: S and removed docs Improvements or additions to documentation scripts Repository scripts extensions: qa-lab size: XL labels Nov 15, 2026
@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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 15, 2026
@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR stops completion retries on permanent Gateway refusals while preserving retries for transient session blocks.

Example: A generated-image completion receives INVALID_REQUEST with retryable false.

  • Before: The completion can keep waking every two seconds after the durable queue has accepted it.
  • After: The refusal produces permanent_failure and ends the completion retry loop.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is focused and source-consistent, but its required real-behavior proof remains mock-only.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Generated-media completion handoffs repeatedly retry a permanent requester refusal for hours.
Reason: The maintainer-authored direction addresses a recorded production failure through existing shared owners and retains transient recovery behavior.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR provides a useful shared retry fix, resolves the earlier queue-ownership finding, and introduces no concrete defect found in this review.

Priority: P2
Reviewed head: a7ca4ac024db6d3046baa89a055c5002d6788480

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted Gateway logs or terminal output showing a generated-media refusal ends retries while a transient workspace block recovers, and identify the new regression’s base-failing/head-passing result.
Agent review details

How this fits together

Generated-media and subagent completions enter the announcement delivery owner, which submits requester turns through the Gateway and translates their results into delivery, retry, or terminal failure.

flowchart TD
  A[Generated media or subagent completion] --> B[Announcement delivery]
  B --> C[Gateway requester turn]
  C --> D[Session work-start policy]
  D --> E[Typed response and retryability]
  E --> F[Shared error classifier]
  F --> G[Retry or settle completion]
Loading

Technical review

Best possible solution:

Keep refusal classification in the shared announcement owner and preserve the existing session policy’s retryability through Gateway responses.

Do we have a high-confidence way to reproduce the issue?

Source tracing establishes the failure path: unrecognized Gateway refusals become retryable, and a previously queued media completion keeps observing without the unconfirmed-handoff deadline; no target code was executed during this review.

Is this the best way to solve the issue?

The patch uses the existing classification and session-policy owners, updates their consumers together, and preserves durable queue ownership without adding another timeout or state owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b09f4a04c8ff.

Provenance checked

  • Announcement error classification keeps the original intent (b3a41e6: The shared classifier traverses wrapped errors to preserve transient recovery, stop permanent failures, and honor send evidence; the later archived-session repair deliberately used narrow wording because retryability was not propagated.)
  • Gateway session work-start responses keeps the original intent (f2b7222: Agent admission reuses the session work-start policy while allowing the existing managed-worktree preparation path; this PR preserves those decisions and exposes their existing retryability.)
  • Queued media completion custody keeps the original intent (ff9985c: Accepted durable work must wait for actual delivery or failure rather than produce a premature timeout warning.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +32, Tests +30. Total +62 across 8 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 5 57 25 +32
Tests 3 35 5 +30
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 92 30 +62

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove merge-risk: 🚨 message-delivery: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Repeated refused completion handoffs cause sustained background retry activity on a limited delivery path.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-15T11:33:32.908Z sha da73f1d :: needs changes before merge. :: [P2] Preserve queue ownership until file delivery actually settles

Reviewed November 15, 2026, 6:59 AM ET / 11:59 UTC (Revision 2).

A queued completion does not mean the files were delivered; the durable
queue can legitimately hold it longer than ten minutes. Refusals now end
after one attempt, which is what stopped the incident, so drop the
queued-wait cap.

Co-authored-by: obviyus <[email protected]>
@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 15, 2026
@obviyus
obviyus merged commit 6f8b9fa into main Nov 15, 2026
133 checks passed
@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

Landed. A refused generated-media completion handoff (INVALID_REQUEST/FORBIDDEN without retryable) now fails after one attempt instead of retrying every 1-2 s until the Gateway restarts; transient blocks such as a workspace that is not ready still retry. Proof: classifier and Gateway handler tests on the exact head, green CI, ClawSweeper ready.

@obviyus
obviyus deleted the openclaw/dawn-krill branch November 15, 2026 12:20
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 16, 2026
…efuses the handoff (openclaw#199575)

## What Problem This Solves

Fixes: a generated image or video completion retries every 1-2 seconds for hours after the requesting run has ended, when the Gateway refuses the completion handoff.

In production, two generated-image completion handoffs retried for 4.5 hours. Every attempt got the same `INVALID_REQUEST` refusal from the Gateway.

## User Impact

User impact: a refused media completion stops after one attempt instead of retrying every 1-2 seconds until the Gateway restarts. Transient blocks such as a workspace that is not ready yet still retry.

## Why This Change Was Made

- **Refusals are terminal.** Completion delivery now treats a typed Gateway `INVALID_REQUEST` or `FORBIDDEN` refusal as a permanent failure. It reads the typed `gatewayCode`, not the message text. `UNAVAILABLE`, transport errors and the existing transient cases still retry.
- **Transient work-start blocks stay retryable.** The agent handler returned some short-lived session states as non-retryable `INVALID_REQUEST`, for example "workspace is not ready" or "still initializing". These states already carry a `retryable` fact. The handler now sends that fact in the Gateway error, so completion delivery can tell a transient block from a refusal. Archived and other permanent blocks are unchanged.
- **Queued delivery stays under queue ownership.** An earlier revision capped the `queued` wait at 10 minutes; review showed `queued` can legitimately outlast that, so the cap was dropped. Refusals ending after one attempt is what stops the incident.

## Evidence

Focused tests (`ocx test`, vitest from source):

- New: `subagent-announce-delivery-retry.test.ts`. A typed `INVALID_REQUEST`, alone or as a cause, is permanent. A retryable `UNAVAILABLE` is not.
- Updated: the gateway agent handler test now checks that the pending-workspace refusal is `retryable: true` and the archived refusal is `retryable: false`. The direct-delivery test fixture for a pending workspace now uses that retryable shape and still expects `retryable`.
- Passing (17 files, 6 shards): the `src/agents/subagents/announce` delivery and media tests, `media-generate-review-delivery.test.ts`, `src/gateway/server-methods/agent.test.ts`, and the gateway agent admission, session persist and session reuse tests.

Gates run locally: `pnpm tsgo:core`, `pnpm check:test-types`, `pnpm check:test-mock-exports`, `pnpm check:max-lines-ratchet`, `pnpm check:line-cap-ratchet`, `pnpm check:assertion-safety`, and oxlint plus format on the changed files.

Not run: the full build and the packed smoke. The change is limited to TypeScript runtime modules and tests, and it changes no build, packaging or public SDK surface. Hosted CI covers the full build. No live Gateway reproduction was run. The behavior is proven at the retry classifier and at the completion loop with fake timers.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant