Skip to content

fix(gateway): report worker errors returned before launch - #124387

Merged
steipete merged 1 commit into
mainfrom
steipete/reverify-regressions
Aug 16, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/reverify-regressions

Conversation

@steipete

@steipete steipete commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a delegated worker rejection returned before the agent-run-start boundary could be delivered internally but recorded as a successful or missing terminal outcome, leaving wait and dedupe clients without the actual error.

Why This Change Was Made

Chat dispatch now treats returned error payloads as authoritative for normal turns whether the worker failed before launch or after the agent run started. Internal text slash commands retain their existing non-agent reply behavior.

User Impact

Waiting clients receive and retain the real worker error when launch is rejected, instead of an ambiguous success or a missing completion.

Evidence

  • Focused Gateway suite: node scripts/run-vitest.mjs src/gateway/server-methods/chat.directive-tags.test.ts — 199 passed on the rebased two-file head.
  • Behavior contract: both post-start and pre-launch worker-error variants broadcast an error state and persist the matching dedupe error; both named variants passed.
  • Production LOC: +10/-11 (net -1); tests: +13/-7 (net +6).
  • Autoreview: clean, no accepted/actionable findings.

Split From The Original PR

The Node bundle prewarm work was removed from this PR. It is parked on steipete/bundle-prewarm-negotiated for a separate draft that requires mixed-version capability negotiation and abort propagation before it can be considered for merge.

@clawsweeper

clawsweeper Bot commented Aug 16, 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 gateway Gateway runtime scripts Repository scripts size: M maintainer Maintainer-authored PR labels Aug 16, 2026
@steipete steipete self-assigned this Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 03:35
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 1:08 AM ET / 05:08 UTC.

ClawSweeper review

What this changes

The PR makes Gateway chat dispatch treat a returned worker error as the terminal result even when the worker rejects before an agent run starts.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

The narrowed PR remains necessary: current main still ignores returned error payloads unless an agent run started, while this branch records and broadcasts those pre-launch errors. The earlier prewarm findings no longer apply after the split; no new blocking defect was found.

Priority: P1
Reviewed head: f9583adfa4330f0854b1056f41052571a35826a3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative owner-boundary repair with direct regression coverage; only normal exact-head CI completion remains.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored Gateway PR is exempt from the external-contributor real-behavior-proof gate; its supplied focused test evidence remains supplemental.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored Gateway PR is exempt from the external-contributor real-behavior-proof gate; its supplied focused test evidence remains supplemental.
Evidence reviewed 7 items Current-main defect: Current main only collects returned error payloads when agentRunStarted is true, so a pre-launch returned error reaches non-agent finalization rather than the error broadcast and dedupe path.
Owner-boundary repair: The PR collects returned errors independently of launch, preserves the internal text-slash-command exception, and uses the existing terminal error broadcast and dedupe owner.
Reply capture contract: The reply dispatcher records final payloads before terminalization regardless of whether an agent run has begun, so dispatch is the correct place to classify the returned error.
Findings None None.
Security None None.

How this fits together

Gateway chat dispatch sends a request into the agent runtime, captures returned reply payloads, then broadcasts and deduplicates the terminal outcome. This change corrects the branch that classifies a pre-launch returned error as a normal reply instead of an error.

flowchart LR
  A[Chat request] --> B[Gateway chat dispatch]
  B --> C[Agent runtime]
  C --> D[Returned reply payload]
  D --> E{Error payload?}
  E -->|Yes| F[Persist terminal error]
  F --> G[Broadcast error to waiting clients]
  E -->|No| H[Normal reply finalization]
Loading

Before merge

  • Resolve merge risk (P1) - The supplied check rollup still has exact-head Gateway-related checks in progress; merge should wait for their completion.
  • Complete next step (P2) - The active maintainer-owned PR already contains the bounded repair; it needs ordinary exact-head CI completion, not a separate repair job.
Agent review details

Security

None.

PR surface

Source -1, Tests +6. Total +5 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 10 11 -1
Tests 1 13 7 +6
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 23 18 +5

Review metrics

Metric Value Why it matters
Production versus test LOC production +10/-11 (net -1); tests +13/-7 (net +6) The bug repair is net-negative in production code while extending one existing boundary test across two launch states.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused terminalization repair once exact-head checks are green, retaining the single error broadcast and dedupe path for both launch states.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the focused terminalization repair once exact-head checks are green, retaining the single error broadcast and dedupe path for both launch states.

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

Yes—current main source excludes pre-launch returned errors at src/gateway/server-methods/chat-send-agent-dispatch.ts:398, and the PR’s focused Gateway fixture isolates that same path.

Is this the best way to solve the issue?

Yes—the dispatch terminalization boundary already owns broadcasts and dedupe entries; changing its classification avoids falsely declaring an agent run started or adding a parallel error path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 203aafc4156c.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored Gateway PR is exempt from the external-contributor real-behavior-proof gate; its supplied focused test evidence remains supplemental.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove merge-risk: 🚨 availability: 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:

  • P1: A returned worker rejection can otherwise leave waiting Gateway clients with a successful or missing terminal outcome instead of the actual error.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored Gateway PR is exempt from the external-contributor real-behavior-proof gate; its supplied focused test evidence remains supplemental.

Evidence

What I checked:

Likely related people:

  • steipete: Reachable main history shows Peter Steinberger authored recent work on this dispatch path, and the current focused repair is authored by the matching GitHub account. (role: recent Gateway contributor; confidence: medium; commits: 8d262b96ccf8, f9583adfa433; files: src/gateway/server-methods/chat-send-agent-dispatch.ts, src/gateway/server-methods/chat.directive-tags.test.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-16T03:43:04.528Z sha 7d1d6eb8114a5f187456a91949a25ec9f96f9ec6 :: found issues before merge. :: [P1] Negotiate prewarming before invoking an older bundle | [P1] Pass cancellation into the prewarm child

@steipete
steipete force-pushed the steipete/reverify-regressions branch from 7d1d6eb to f9583ad Compare August 16, 2026 05:02
@openclaw-barnacle openclaw-barnacle Bot added size: XS and removed scripts Repository scripts size: M labels Aug 16, 2026
@steipete steipete changed the title fix(gateway): keep node worker turns responsive and truthful fix(gateway): report worker errors returned before launch Aug 16, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Split applied as requested.

  • This PR is now the two-file terminal-truth repair only: chat dispatch plus its focused regression.
  • The prewarm implementation and load scenario were removed from this head.
  • The two prewarm commits are parked on steipete/bundle-prewarm-negotiated for a separate draft.
  • The review's compatibility and availability findings remain requirements for that draft: negotiate the prewarm capability across mixed Gateway/node versions and propagate cancellation through the prewarm child so a canceled install cannot hold the namespace queue.

The thin head is f9583adfa43, rebased onto current main. Focused proof is 199 passing Gateway tests plus the before-launch/after-start behavior contract; autoreview is clean.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 16, 2026
@steipete
steipete merged commit eae415b into main Aug 16, 2026
198 checks passed
@steipete
steipete deleted the steipete/reverify-regressions branch August 16, 2026 05:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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