Skip to content

refactor(cli)!: remove automatic gateway→embedded fallback from openclaw agent#112074

Merged
steipete merged 1 commit into
mainfrom
claude/fallback-behavior-discussion-19e531
Jul 21, 2026
Merged

refactor(cli)!: remove automatic gateway→embedded fallback from openclaw agent#112074
steipete merged 1 commit into
mainfrom
claude/fallback-behavior-discussion-19e531

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

When the CLI↔Gateway agent websocket timed out or closed mid-turn, openclaw agent silently re-ran the entire turn embedded in-process under a fresh gateway-fallback-<uuid> session. That automatic fallback had three structural problems:

  1. Double execution of side effects. Transport loss is ambiguous: the Gateway may have accepted — and may still finish — the original turn (the CLI's default 600s deadline vs the Gateway's 48h turn deadline makes this realistic, per docs/cli/agent.md). The embedded re-run then executes the same message a second time: tools fire twice, messages send twice.
  2. Continuity lie. --session-key callers got a status-ok reply from a fresh session with no conversation context — a result they should discard, produced at full cost.
  3. Wrong host. The embedded run used the CLI host's local config/credentials, which is quietly wrong for a thin client pointed at a remote Gateway.

Two prior patches (a428765 fresh-session isolation, #111645 structured divergence marker) existed solely to fence confusion the fallback itself created.

Why This Change Was Made

Per the repo architecture bar, fallback is a product decision: name the shipped contract, failure mode, and removal plan — or delete it. The failure mode here is silent duplicate execution; the mechanism users actually need (--local) already exists as an explicit flag. Maintainer decision: remove the automatic path entirely.

User Impact

  • A Gateway timeout / closed connection now fails the command (original error rethrown, non-zero exit) after the existing transient handshake retries, with a stderr hint: check openclaw gateway status and the session transcript before retrying or rerunning with --local, so an ambiguously-accepted turn is not executed twice. The hint deliberately does not recommend a blind retry, and does not present --local as session-isolated (it reuses the requested session key).
  • --local is now the only embedded execution path; behavior of --local itself is unchanged.
  • --json no longer emits meta.transport: "embedded" / meta.fallbackFrom / meta.fallbackReason / meta.fallback — these markers existed only to describe fallback runs (the meta.fallback shape shipped <1 day ago in fix(cli): surface gateway→embedded fallback session divergence in --json output #111645). Scripts now see a clean non-zero exit instead of a divergent success.
  • Internal cleanup: the resultMetaOverrides plumbing (AgentCommandResultMetaOverrides, delivery-time merge) is deleted — the fallback was its only writer. Plugin SDK API manifest regenerated for the one-field shrink of AgentCommandOpts (internal-caller field; the type name was never exported by the SDK barrels).
  • Docs updated: docs/cli/agent.md, docs/tools/agent-send.md, docs/automation/cron-jobs.md.

Evidence

  • Net diff: +95 / −575 across 10 files; no live gateway-fallback / resultMetaOverrides references remain (repo-wide grep; one historical CHANGELOG entry untouched).
  • Blacksmith Testbox tbx_01ky1f2xp98kv6r8ng82mrxmsb: focused pnpm test src/commands/agent-via-gateway.test.ts (71/71), src/agents/command/delivery.test.ts (52/52), src/cli/run-main.exit.test.ts — all green; full pnpm check:changed exit 0 (typecheck, lint, format, SDK manifest gates).
  • New tests assert: timeout and transport-closed errors reject with the original error, the embedded command is never invoked, the --local hint appears; non-transport errors reject without the hint; transient handshake retries still run 6 attempts before failing.
  • AutoReview (Codex gpt-5.6-sol, xhigh): two P1s on the initial hint wording (blind-retry advice; --local mis-described as fresh-session) — both fixed; final run clean, "patch is correct (0.93)".

…law agent

A Gateway timeout or closed connection now fails the command with an
actionable stderr hint instead of silently re-running the whole turn
embedded under a fresh gateway-fallback-* session. The silent fallback
could double-execute side effects (the Gateway may still finish an
accepted turn), returned context-free answers to --session-key callers,
and ran with the CLI host's local config. --local remains the only
embedded execution path.

Also deletes the resultMetaOverrides plumbing (the fallback was its only
writer) and the fallback marker fields added in #111645.
@steipete
steipete marked this pull request as ready for review July 21, 2026 04:58
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes commands Command implementations agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Jul 21, 2026
@clawsweeper

clawsweeper Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: refactor(cli)!: remove automatic gateway→embedded fallback from openclaw agent This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete
steipete merged commit c5254f1 into main Jul 21, 2026
205 of 217 checks passed
@steipete
steipete deleted the claude/fallback-behavior-discussion-19e531 branch July 21, 2026 06:30
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Jul 21, 2026
…lback removal (#112191)

Follow-up to c5254f1 (#112074): delete the legacy string-match timeout
classifier (the CLI path only sees typed GatewayTransportError from
callGateway's wrapper timer), the duplicate JSON/blank-message validation
in the private gateway command, the now-pointless getGatewayDispatchConfig
wrapper, the single-use embedded-loader alias, and the cross-os release
guard for the EMBEDDED FALLBACK marker no build can emit anymore.
vincentkoc added a commit that referenced this pull request Jul 21, 2026
* origin/main: (24 commits)
  fix(agents): keep compaction on live session model (#95713)
  fix(plugin-sdk): guard provider catalog live URL parsing against malformed responses (#109986)
  chore(cli): drop dead classifiers and single-use wrappers left by fallback removal (#112191)
  feat(ui): expand the lobster pet's random universe (#112073)
  chore(ci): audit dependency fingerprint exports (#112190)
  fix(ui): preserve graphemes in provider icons (#109509)
  fix(ui): align settings search with navigation rows (#112172)
  fix(agents): allow configless gateway rebind to activate standalone owner (#111841)
  fix(secrets): register secret targets for installed-origin plugins (#104347)
  improve(ui): show real machine identity in the place picker (#112162)
  fix: webChat scrollback history is too limited — older assistant replies and tool outputs disappear when scrolling… (#104250)
  test(ui): run DOM-free suites in Node (#112031)
  feat(nodes): make computer.act eligibility capability-based for desktop nodes (#112107)
  fix(apps): harden mobile gateway and watch state
  fix(ci): restore Z.AI API Platform validation (#112171)
  fix(ui): prevent Logs controls from overlapping (#112170)
  fix #95291: message tool fails to deliver files/images on Feishu (400 volc-dcdn / write ECONNRESET) while same Lark SDK upload succeeds standalone (#95514)
  refactor(cli)!: remove automatic gateway→embedded fallback from openclaw agent (#112074)
  refactor: move provider transports into packages/ai behind a typed host port (#111669)
  fix(anthropic): complete transcript reverse-scan windows across short reads (#109431)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 22, 2026
…law agent (openclaw#112074)

A Gateway timeout or closed connection now fails the command with an
actionable stderr hint instead of silently re-running the whole turn
embedded under a fresh gateway-fallback-* session. The silent fallback
could double-execute side effects (the Gateway may still finish an
accepted turn), returned context-free answers to --session-key callers,
and ran with the CLI host's local config. --local remains the only
embedded execution path.

Also deletes the resultMetaOverrides plumbing (the fallback was its only
writer) and the fallback marker fields added in openclaw#111645.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 22, 2026
…lback removal (openclaw#112191)

Follow-up to 2357629 (openclaw#112074): delete the legacy string-match timeout
classifier (the CLI path only sees typed GatewayTransportError from
callGateway's wrapper timer), the duplicate JSON/blank-message validation
in the private gateway command, the now-pointless getGatewayDispatchConfig
wrapper, the single-use embedded-loader alias, and the cross-os release
guard for the EMBEDDED FALLBACK marker no build can emit anymore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes commands Command implementations docs Improvements or additions to documentation maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant