Skip to content

fix(exec): surface ambiguous node outcomes without retrying - #117276

Merged
omarshahine merged 1 commit into
omarshahine-gateway-invoke-provenancefrom
omarshahine-omarshahine-exec-outcome-unknown-stack
Aug 1, 2026
Merged

omarshahine merged 1 commit into
omarshahine-gateway-invoke-provenancefrom
omarshahine-omarshahine-exec-outcome-unknown-stack

Conversation

@omarshahine

@omarshahine omarshahine commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Node-host exec could project timeout, disconnect, or malformed post-invoke failures as denial or non-dispatch even when the Gateway could not prove whether system.run executed. That could prompt an unsafe automatic retry and duplicate side effects.

This PR is Layer 3 of the native PR stack. It is stacked on #117139 at exact base SHA 8fbbb9cbe13d08894794712455a45e1aca553c9c and depends on that PR landing first. The Layer 3 diff is exactly 14 intended files; it inherits but does not modify Layer 2's regenerated browser runtime.

Why This Change Was Made

Consume the Gateway dispatch provenance added by #117139 at a single node-invoke boundary. Only NOT_CONNECTED with explicit nodeCommandDispatched:false is classified as retry-safe not-dispatched; every timeout, disconnect, post-dispatch, missing-provenance, or malformed result is classified as outcome-unknown.

The current-main approval continuation contract is preserved: canonical buildExecApprovalContinuationPrompt(...).message, authenticated untrusted-output delimiters, bounded output, redaction, runtime/session handoff, and normal continuation fallback. Distinct outcome-unknown and not-dispatched guidance is selected before that canonical handoff. Detached invocation classification is completed before follow-up delivery so a delivery failure cannot become a false denial.

Compatibility decision

The conservative mixed-version contract is intentional. An updated agent talking to a stale Gateway that omits explicit dispatch provenance receives outcome-unknown and does not retry automatically. Only NOT_CONNECTED with explicit nodeCommandDispatched:false is retry-safe not-dispatched. At-most-once side-effect safety intentionally wins over automatic stale-Gateway recovery.

User Impact

Users and models now see that an ambiguous node command may have executed and must not be rerun automatically. Direct, inline-approved, detached-approved, embedded tool events, and Gateway agent-event projections retain typed failure details. Existing success and denial behavior is unchanged.

Evidence

  • 18 focused node phases/host/cancellation, approval output/follow-up/continuation, parser, embedded-handler, Gateway event, and parent Gateway proof files: 706 tests passed across five Vitest shards.
  • Plugin-policy route/send provenance lane: 3 files, 90 tests passed.
  • Production and test tsgo: passed.
  • Targeted Oxfmt and Oxlint: passed.
  • Dead exports and unused files: zero findings.
  • Deprecated API, Plugin SDK API, and Plugin SDK surface gates: passed.
  • build:ci-artifacts: passed and left the Layer 3 worktree clean.
  • git diff --check: passed.
  • Fresh exact-head Codex autoreview: no accepted/actionable findings, correctness 0.96.
  • Hosted Testbox was unavailable because the local blacksmith executable is missing; trusted-source local fallback completed the heavy gates.

Exact-head immutable paired-node proof

  • Head: d1f786f1567b78493bb06a830a53f812b684b414.
  • Parent and merge-base: 8fbbb9cbe13d08894794712455a45e1aca553c9c.
  • Source archive: openclaw-d1f786f1567b78493bb06a830a53f812b684b414.tar.
  • Archive SHA-256: c2c771e8fee6f9a10a1f8fe254959d3dfe65f61c01f99fece89b3507d51418a5.
  • Fresh frozen install and exact-head build: passed.
  • Isolated proof used Gateway port 29789, mock Responses port 29790, proof-owned state, a fresh signed node identity, normal pairing, explicit command-surface approval, and node approvals security:"full", ask:"off", askFallback:"full".

Redacted observed outcomes:

Path Gateway/caller result Side-effect proof
Raw pre-dispatch disconnected Outer UNAVAILABLE; details.code:"NOT_CONNECTED", nested nodeError.code:"NOT_CONNECTED", nodeCommandDispatched:false Marker absent before reconnect and after reconnect
Detached approved pre-dispatch disconnected Authenticated follow-up says not dispatched, did not run, and retry only after reconnecting; canonical untrusted-output delimiters retained Marker absent before reconnect and after reconnect
Direct post-dispatch Gateway timeout Sanitized event isError:true, reason:"outcome-unknown", failureCode:"TIMEOUT", nodeCommandDispatched:true; caller says it may have executed and must not be rerun automatically Unique marker exactly once; one exec result; no retry
Direct post-dispatch disconnect Sanitized event isError:true, reason:"outcome-unknown", failureCode:"DISCONNECTED", nodeCommandDispatched:true; caller says it may have executed and must not be rerun automatically Unique marker exactly once; one exec result; no retry
Detached approved timeout and disconnect Each authenticated follow-up says outcome-unknown, may have executed, and do not rerun automatically; canonical untrusted-output delimiters retained Unique marker exactly once per path; exactly one follow-up per path; no second exec

All proof-owned node, Gateway, and mock-provider processes were stopped. Ports 29789 and 29790 were verified closed.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Aug 1, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 5:05 PM ET / 21:05 UTC.

ClawSweeper review

What this changes

This PR makes node-host exec report timeout, disconnect, malformed, and missing-provenance failures as potentially executed, allowing retry only for an explicitly pre-dispatch NOT_CONNECTED result.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep this PR open for maintainer review. Current main still sends node invocations through the older direct path, while this branch depends on the open Gateway provenance layer; the proposed conservative retry policy is plausible and its supplied paired-node proof is strong, but the stack must be landed or rebased as an integrated unit before merge.

Priority: P1
Reviewed head: d1f786f1567b78493bb06a830a53f812b684b414
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong exact-head behavioral evidence and focused coverage support the patch; the remaining blocker is stacked integration and maintainer ownership of the compatibility decision.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body supplies exact-head paired-node after-fix evidence with redacted terminal outcomes and side-effect markers for both retry-safe and ambiguous execution paths.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies exact-head paired-node after-fix evidence with redacted terminal outcomes and side-effect markers for both retry-safe and ambiguous execution paths.
Evidence reviewed 7 items Current-main behavior remains unfixed: The checked-out parent of current main directly invokes node.invoke in both direct and inline-approved execution paths. The current-main commit changes only src/gateway/control-ui-session-prs-branch.test.ts, so these agent sources remain current-main behavior.
Patch centralizes the retry-safety decision: The branch catches non-cancellation invocation failures, classifies only explicit NOT_CONNECTED plus nodeCommandDispatched:false as retry-safe, and renders typed failed tool details for all other outcomes.
Direct and approved paths use the common classifier: The patch routes inline execution, approval follow-up execution, and direct node-host execution through the same invokeNodeSystemRun boundary before emitting tool or follow-up text.
Findings None None.
Security None None.

How this fits together

Node-host exec turns an agent command into a Gateway node.invoke call for a paired device. The result then feeds either an immediate tool response or an approved-command follow-up, where the model must know whether retrying could duplicate a side effect.

flowchart LR
  A[Agent exec request] --> B[Node-host execution]
  B --> C[Gateway node invoke]
  C --> D[Dispatch provenance]
  D --> E[Proven not dispatched]
  D --> F[Outcome unknown]
  E --> G[Safe retry guidance]
  F --> H[Do not retry guidance]
  G --> I[Tool result or approval follow-up]
  H --> I
Loading

Decision needed

Question Recommendation
Should the maintainer accept the stack’s conservative mixed-version contract—treating missing Gateway dispatch provenance as outcome-unknown rather than retrying—and land the Gateway producer before this agent consumer? Land the full conservative stack: Merge the Gateway provenance producer first, then rebase this consumer on current main and retain outcome-unknown behavior for stale or malformed provenance.

Why: This is an intentional compatibility tradeoff across two open stacked PRs, not a mechanical defect that review automation can safely resolve without confirming the permanent Gateway-to-agent contract.

Before merge

  • Resolve merge risk (P1) - The branch depends on the open Gateway provenance PR at https://github.com/openclaw/openclaw/pull/117139; both commits are outside current main and the stack needs a refreshed integrated head before merge.
  • Resolve merge risk (P2) - The deliberate mixed-version behavior changes a stale Gateway from automatic retry fallback to an outcome-unknown failure, which protects at-most-once effects but can stop an existing recovery path until the Gateway is updated or restarted.
  • Resolve merge risk (P1) - The concrete Gateway producer shape for nested node errors could not be independently read because required promisor blobs were unavailable and network DNS failed; the stack’s integrated review should verify that contract at the merged head.
Agent review details

Security

None.

PR surface

Source +295, Tests +571. Total +866 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 7 330 35 +295
Tests 7 571 0 +571
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 901 35 +866

Review metrics

None.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/agents/exec-approval-result.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Land the producer, then refresh this consumer (recommended)
    Merge the Gateway provenance PR first, rebase this branch onto current main, and rerun exact-head paired-node proof for both explicit pre-dispatch and ambiguous outcomes.
  2. Accept the conservative stale-Gateway behavior
    Maintainers may intentionally accept outcome-unknown without automatic recovery for old Gateways because retrying could duplicate a command side effect.
  3. Pause the stacked approach
    Pause this PR if maintainers want a different long-term Gateway-to-agent retry contract before exposing the new failure classification.

Technical review

Best possible solution:

Land or consolidate the Gateway provenance layer first, then retarget/rebase this consumer onto current main and confirm the combined runtime still preserves the explicit pre-dispatch-only retry contract.

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

Yes, source-reproducible: current main directly treats the node invoke as a normal result path, and the branch’s focused tests model timeout, disconnect, missing-provenance, and pre-dispatch failures. The reported paired-node execution was not rerun in this read-only review.

Is this the best way to solve the issue?

Unclear: centralizing the classification before direct, inline-approved, and detached follow-up projections is the right owner boundary, but the required Gateway producer contract could not be fully inspected locally and the mixed-version tradeoff needs maintainer confirmation.

AGENTS.md: unclear because the file could not be read completely.

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

Labels

Label justifications:

  • P1: Ambiguous node command outcomes can cause an agent to retry a command that may already have executed, affecting active remote-command workflows.
  • merge-risk: 🚨 compatibility: The branch intentionally removes stale-Gateway automatic retry when dispatch provenance is absent, changing recovery behavior for mixed-version deployments.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies exact-head paired-node after-fix evidence with redacted terminal outcomes and side-effect markers for both retry-safe and ambiguous execution paths.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head paired-node after-fix evidence with redacted terminal outcomes and side-effect markers for both retry-safe and ambiguous execution paths.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Current node-host invocation and approval-follow-up lines trace to this recent agent-path commit, and the file history contains several earlier exec and node-host repairs by the same contributor. (role: recent area contributor; confidence: high; commits: 7ab05df415a4, 68694599af6f; files: src/agents/bash-tools.exec-host-node.ts, src/agents/bash-tools.exec-host-node-phases.ts)
  • Vincent Koc: The recent history includes the current continuation-output repair, which is the model-facing handoff this PR extends with outcome-specific guidance. (role: adjacent approval-continuation contributor; confidence: medium; commits: 602b5759f281; files: src/agents/bash-tools.exec-approval-output.ts, src/agents/bash-tools.exec-approval-followup.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase or retarget the complete two-PR stack onto current main after the Gateway producer lands.
  • Repeat the paired-node proof against that integrated head and confirm the Gateway error producer still emits the consumed provenance shape.

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 (8 earlier review cycles)
  • reviewed 2026-08-01T07:26:40.465Z sha 986d75a :: needs real behavior proof before merge. :: [P2] Give outcome-unknown failures a safe recovery action
  • reviewed 2026-08-01T11:59:01.291Z sha 986d75a :: needs real behavior proof before merge. :: [P1] Use the current direct invocation timeout field | [P3] Use the shared non-array record guard
  • reviewed 2026-08-01T12:20:22.628Z sha 986d75a :: needs real behavior proof before merge. :: [P3] Use the canonical non-array record guard
  • reviewed 2026-08-01T15:38:22.016Z sha aa41fdc97e07bec03480c6c63cec3b12dbddfe45 :: needs real behavior proof before merge. :: [P3] Use the canonical non-array record guard
  • reviewed 2026-08-01T16:02:30.767Z sha f54f03d :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T16:39:59.442Z sha 72e1616 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T16:48:06.612Z sha 72e1616 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T20:53:46.906Z sha 72e1616 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 1, 2026
@omarshahine
omarshahine force-pushed the omarshahine-omarshahine-exec-outcome-unknown-stack branch from 986d75a to aa41fdc Compare August 1, 2026 15:31
@omarshahine
omarshahine force-pushed the omarshahine-omarshahine-exec-outcome-unknown-stack branch from aa41fdc to f54f03d Compare August 1, 2026 15:56
@omarshahine

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@omarshahine
omarshahine force-pushed the omarshahine-omarshahine-exec-outcome-unknown-stack branch from f54f03d to 72e1616 Compare August 1, 2026 16:33
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 1, 2026
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: aeb0d377-8525-47eb-a494-a1721ff44d87
@omarshahine omarshahine self-assigned this Aug 1, 2026
@omarshahine
omarshahine force-pushed the omarshahine-omarshahine-exec-outcome-unknown-stack branch from 72e1616 to d1f786f Compare August 1, 2026 20:59
@omarshahine

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@omarshahine

Copy link
Copy Markdown
Contributor Author

Maintainer decision: accepted.

For this stack, retry safety requires a proven pre-dispatch failure: NOT_CONNECTED with nodeCommandDispatched: false. Missing provenance, timeout, disconnect, and malformed outcomes remain outcome-unknown and must not be retried automatically. At-most-once side-effect safety intentionally takes precedence over automatic recovery against a stale Gateway.

Land the native stack bottom-to-top after its lower layers are ready. This comment records the compatibility decision only and does not request automation.

@omarshahine
omarshahine merged commit b82dd01 into main Aug 1, 2026
126 checks passed
@omarshahine
omarshahine deleted the omarshahine-omarshahine-exec-outcome-unknown-stack branch August 1, 2026 21:22
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
…#117276)

Co-authored-by: Copilot App <[email protected]>

Co-authored-by: Omar Shahine <[email protected]>
Copilot-Session: aeb0d377-8525-47eb-a494-a1721ff44d87
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 maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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