Skip to content

fix(agents): skip auth gate for CLI-owned transport - #88551

Merged
vincentkoc merged 3 commits into
openclaw:mainfrom
yu-xin-c:codex/fix-cli-owned-auth-gate
Jun 19, 2026
Merged

vincentkoc merged 3 commits into
openclaw:mainfrom
yu-xin-c:codex/fix-cli-owned-auth-gate

Conversation

@yu-xin-c

@yu-xin-c yu-xin-c commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Skip the model-fallback auth cooldown gate for explicitly configured CLI agent runtimes such as anthropic/* with agentRuntime.id: "claude-cli".
  • Keep the attempt-level auth-profile selection guard so CLI-owned transports preserve only authProfileProvider when auth-profile forwarding is disabled.

What changed after review

  • Rebased onto current main.
  • Added the fallback-boundary fix requested by review: CLI runtime candidates now set skipsProviderAuthCooldown: true before the fallback loop evaluates stale OpenClaw provider auth state.
  • Added production-path coverage through runWithModelFallback with anthropic/*, claude-cli, and stale provider auth state.
  • Kept the direct runAgentAttempt coverage showing authProfileId stays unset while the CLI-owned route still runs.

Real behavior proof

Behavior or issue addressed: A configured CLI-owned runtime such as anthropic/claude-sonnet-4-6 with agentRuntime.id: "claude-cli" should be allowed to run even when OpenClaw has stale provider auth cooldown state for anthropic:default. The downstream CLI attempt must also avoid auto-filling authProfileId when auth-profile forwarding is disabled.

Real environment tested: Live PR branch checkout at 78ddcb5bdc61030285dc9baed100e74c184aa949, local path /private/tmp/openclaw-88551-clone, macOS shell, Node v22.22.2, corepack pnpm 11.2.2.

Exact steps or command run after this patch: I ran the copied live terminal commands below on the PR branch checkout after this patch:

git rev-parse --short HEAD
node scripts/run-vitest.mjs run src/agents/model-fallback.test.ts -t 'lets configured CLI runtimes bypass stale provider auth cooldowns' --reporter verbose
node scripts/run-vitest.mjs run src/agents/command/attempt-execution.cli.test.ts -t 'skips auto auth-profile resolution for CLI-owned transport' --reporter verbose
./node_modules/.bin/oxfmt --check --threads=1 src/agents/model-fallback.ts src/agents/model-fallback.test.ts src/agents/command/attempt-execution.ts src/agents/command/attempt-execution.cli.test.ts src/agents/fallback-skip-cache.ts packages/terminal-core/src/ansi.ts

Evidence after fix: Copied terminal transcript / live output from the PR branch checkout:

$ git rev-parse --short HEAD
78ddcb5b
$ node --version
v22.22.2
$ corepack pnpm --version
11.2.2
$ node scripts/run-vitest.mjs run src/agents/model-fallback.test.ts -t 'lets configured CLI runtimes bypass stale provider auth cooldowns' --reporter verbose
RUN  v4.1.7 /private/tmp/openclaw-88551-clone
✓ |agents-core| ../../src/agents/model-fallback.test.ts > runWithModelFallback > lets configured CLI runtimes bypass stale provider auth cooldowns 12ms
✓ |agents-support| ../../src/agents/model-fallback.test.ts > runWithModelFallback > lets configured CLI runtimes bypass stale provider auth cooldowns 11ms

Test Files  2 passed (2)
Tests  2 passed | 152 skipped (154)

$ node scripts/run-vitest.mjs run src/agents/command/attempt-execution.cli.test.ts -t 'skips auto auth-profile resolution for CLI-owned transport' --reporter verbose
RUN  v4.1.7 /private/tmp/openclaw-88551-clone
✓ |agents-core| ../../src/agents/command/attempt-execution.cli.test.ts > CLI attempt execution > skips auto auth-profile resolution for CLI-owned transport 5ms
✓ |agents-support| ../../src/agents/command/attempt-execution.cli.test.ts > CLI attempt execution > skips auto auth-profile resolution for CLI-owned transport 6ms

Test Files  2 passed (2)
Tests  2 passed | 70 skipped (72)

$ ./node_modules/.bin/oxfmt --check --threads=1 src/agents/model-fallback.ts src/agents/model-fallback.test.ts src/agents/command/attempt-execution.ts src/agents/command/attempt-execution.cli.test.ts src/agents/fallback-skip-cache.ts packages/terminal-core/src/ansi.ts
Checking formatting...
All matched files use the correct format.
Finished in 44ms on 6 files using 1 threads.

Observed result after fix: The model fallback path reaches the configured claude-cli runtime even with stale Anthropic provider auth cooldown state, and the CLI-owned attempt path still runs with authProfileId unset when auth-profile forwarding is disabled.

What was not tested: No additional gaps for the reviewed fallback/auth-profile behavior. I did not run a real Claude CLI network turn against Anthropic; the after-fix proof covers the OpenClaw fallback and CLI attempt routing behavior changed in this PR.

Verification

  • node scripts/run-vitest.mjs run src/agents/model-fallback.test.ts -t 'lets configured CLI runtimes bypass stale provider auth cooldowns' --reporter verbose
  • node scripts/run-vitest.mjs run src/agents/command/attempt-execution.cli.test.ts -t 'skips auto auth-profile resolution for CLI-owned transport' --reporter verbose
  • ./node_modules/.bin/oxfmt --check --threads=1 src/agents/model-fallback.ts src/agents/model-fallback.test.ts src/agents/command/attempt-execution.ts src/agents/command/attempt-execution.cli.test.ts src/agents/fallback-skip-cache.ts packages/terminal-core/src/ansi.ts

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 31, 2026
@byungskers

Copy link
Copy Markdown

This looks like the right direction for CLI-owned transports. One small follow-up I would love to see called out in coverage: the early return now preserves only authProfileProvider when forwarding is disabled. Can you add/assert the exact downstream behavior you want there (for example that authProfileId stays unset while the provider still resolves to the CLI-owned route)? That would make the intent of the partial selection object a lot clearer for future refactors.

@clawsweeper

clawsweeper Bot commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 18, 2026, 9:34 PM ET / 01:34 UTC.

Summary
The PR changes model fallback and attempt execution so configured and direct CLI-owned runtimes bypass OpenClaw provider cooldown preflight and avoid auto-forwarded auth profiles unless the CLI backend supports forwarding.

PR surface: Source +6, Tests +144. Total +150 across 4 files.

Reproducibility: yes. source-reproducible: current main still returns skipsProviderAuthCooldown: false for CLI-owned candidates before the cooldown gate, and the PR tests exercise stale auth state on the affected paths.

Review metrics: 1 noteworthy metric.

  • Auth Routing Gates: 2 cooldown bypasses changed, 1 auth-profile preselection guard added. These gates decide whether stale provider auth state or stored auth profiles can affect CLI-owned transports before startup.

Stored data model
Persistent data-model change detected: serialized state: src/agents/command/attempt-execution.cli.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] Merging intentionally changes auth/provider routing: stale OpenClaw provider cooldowns no longer stop direct or configured CLI-owned candidates before the CLI starts, so downstream CLI auth failures surface later instead.
  • [P1] The supplied proof covers OpenClaw routing and attempt-selection behavior, but it does not include a live Claude CLI or Codex CLI network turn after the gate is bypassed.

Maintainer options:

  1. Accept CLI-Owned Auth Boundary (recommended)
    Land after required checks if maintainers agree that direct and configured CLI runtimes should own their auth failures instead of being blocked by stale OpenClaw provider cooldown state.
  2. Require Live CLI Smoke
    Ask for a redacted live Claude CLI or Codex CLI turn if maintainers want end-to-end backend auth evidence before accepting the routing change.
  3. Pause For Broader Auth Metadata
    Pause or close if maintainers want a metadata-driven auth ownership API instead of this narrow fallback-boundary repair.

Next step before merge

  • No automated repair is needed; a maintainer should accept or reject the CLI-owned auth boundary and wait for required checks before merge.

Security
Cleared: No concrete security or supply-chain regression was found; the diff changes in-repo auth routing logic and tests without new dependencies, workflows, permissions, or secret handling expansion.

Review details

Best possible solution:

Land the focused bypass after maintainers accept the CLI-owned auth boundary, while keeping OpenClaw provider cooldown gating for non-CLI and OpenClaw-managed runtimes.

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

Yes, source-reproducible: current main still returns skipsProviderAuthCooldown: false for CLI-owned candidates before the cooldown gate, and the PR tests exercise stale auth state on the affected paths.

Is this the best way to solve the issue?

Yes, this is the narrow best fix subject to maintainer acceptance: it reuses existing CLI runtime detection and preserves OpenClaw cooldown gating for non-CLI/OpenClaw-managed runtimes instead of adding a broader new API.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal output for the changed routing tests, and latest-head automation reports the real behavior proof check passing on 07cc2d0.

Label justifications:

  • P2: This is a focused agents/auth-provider bug fix with real workflow impact but a limited configured and direct CLI-runtime surface.
  • merge-risk: 🚨 auth-provider: The diff changes when provider auth cooldown state and auth-profile selection can affect CLI-owned runtimes.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes after-fix terminal output for the changed routing tests, and latest-head automation reports the real behavior proof check passing on 07cc2d0.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal output for the changed routing tests, and latest-head automation reports the real behavior proof check passing on 07cc2d0.
Evidence reviewed

PR surface:

Source +6, Tests +144. Total +150 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 7 1 +6
Tests 2 145 1 +144
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 152 2 +150

Acceptance criteria:

  • [P2] node scripts/run-vitest.mjs run src/agents/model-fallback.test.ts -t 'lets configured CLI runtimes bypass stale provider auth cooldowns' --reporter verbose.
  • [P1] node scripts/run-vitest.mjs run src/agents/command/attempt-execution.cli.test.ts -t 'skips auto auth-profile resolution for CLI-owned transport' --reporter verbose.
  • [P1] pnpm check:changed.

What I checked:

  • Repository policy applied: Root AGENTS.md and the scoped src/agents guide were read; their read-beyond-diff, auth-provider compatibility, and Codex-source gates shaped this review. (AGENTS.md:10, 2ef0589b760d)
  • Current main still gates CLI-owned candidates: On current main, direct CLI providers and configured CLI agent runtimes both return skipsProviderAuthCooldown: false before the fallback cooldown gate. (src/agents/model-fallback.ts:522, 2ef0589b760d)
  • Cooldown flag controls the failure path: The fallback loop only applies provider auth cooldown filtering when candidateHarnessAuth.skipsProviderAuthCooldown is false, so the PR changes the relevant runtime gate. (src/agents/model-fallback.ts:1472, 2ef0589b760d)
  • Current main can auto-select harness auth before the no-forwarding case: Current main builds the runtime auth plan before any early no-forwarding return, while runAgentAttempt passes allowHarnessAuthProfileForwarding false for CLI execution providers. (src/agents/command/attempt-execution.ts:184, 2ef0589b760d)
  • PR head changes the fallback boundary: The PR head returns skipsProviderAuthCooldown: true for direct CLI providers and configured CLI agent runtimes, preserving the existing OpenClaw-managed and plugin-harness branches. (src/agents/model-fallback.ts:522, 07cc2d0866e3)
  • PR head adds the no-forwarding guard: The PR head returns only authProfileProvider when harness auth-profile forwarding is disabled, leaving authProfileId unset for CLI-owned transport paths unless a CLI backend explicitly stages profiles. (src/agents/command/attempt-execution.ts:184, 07cc2d0866e3)

Likely related people:

  • vincentkoc: Current main blame and PR discussion tie Vincent Koc to the reviewed model-fallback and attempt-execution surfaces, and he posted latest-head validation for the repaired branch. (role: recent area contributor and branch refresh owner; confidence: high; commits: 7ef85bfb1d, 4106794ff515, 160aad6fb359; files: src/agents/model-fallback.ts, src/agents/command/attempt-execution.ts)
  • steipete: The merged plugin-harness stale-auth fix fix(agents): bypass stale auth for plugin harnesses #89305 shares the model-fallback auth precheck surface and was authored by steipete. (role: adjacent stale-auth fix author; confidence: high; commits: b7d363cadff4; files: src/agents/model-fallback.ts, src/agents/model-fallback.test.ts)
  • shakkernerd: Recent history on attempt execution and CLI runner preparation includes multiple CLI auth/profile staging changes near the PR's no-forwarding guard. (role: adjacent CLI auth-profile contributor; confidence: medium; commits: defaffbb9375, 8d3929e86ff5, 17ba3bc65d3f; files: src/agents/command/attempt-execution.ts, src/agents/cli-runner/prepare.ts)
  • byungskers: The PR discussion requested the downstream authProfileId coverage that the latest branch now includes. (role: reviewer; confidence: medium; files: src/agents/command/attempt-execution.cli.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels May 31, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 31, 2026
@yu-xin-c
yu-xin-c force-pushed the codex/fix-cli-owned-auth-gate branch 2 times, most recently from 7319c65 to 78ddcb5 Compare June 2, 2026 17:10
@yu-xin-c

yu-xin-c commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Updated this PR to address the fallback-boundary review finding.

What changed:

  • Rebased onto current main.
  • Mirrored the bypass into runWithModelFallback: explicitly configured CLI runtimes now skip stale OpenClaw provider auth cooldown before the attempt callback.
  • Added production-path regression coverage for anthropic/* with agentRuntime.id: "claude-cli" and disabled/stale anthropic:default auth state.
  • Kept the direct attempt coverage requested by @byungskers: the CLI-owned route runs while authProfileId remains unset when auth forwarding is disabled.

The new head is 78ddcb5bdc61030285dc9baed100e74c184aa949.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 2, 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: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. proof: supplied External PR includes structured after-fix real behavior proof. and removed proof: supplied External PR includes structured after-fix real behavior proof. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 2, 2026
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 4, 2026
@yu-xin-c

yu-xin-c commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Follow-up after the Real behavior proof body update: the current head 78ddcb5bdc61030285dc9baed100e74c184aa949 now has the latest Real behavior proof check passing, and there are no latest-head failing checks. Please re-check the current head for merge readiness.

@clawsweeper

clawsweeper Bot commented Jun 6, 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: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added 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. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jun 6, 2026
@vincentkoc
vincentkoc force-pushed the codex/fix-cli-owned-auth-gate branch from 78ddcb5 to be65747 Compare June 19, 2026 00:41
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 19, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Clownfish 🐠 reef update

Thanks for the contribution here. Clownfish gave the branch a tidy little reef repair and kept this PR as the main lane.

Source PR: #88551
Validation: pnpm test src/agents/command/attempt-execution.cli.test.ts src/agents/model-fallback.test.ts; pnpm check:changed
Contributor credit stays right here with this PR's history and changelog context. no lost treasure, no mystery bubbles.

fish notes: model gpt-5.5, reasoning medium; reviewed against d849849451e2.

@vincentkoc
vincentkoc force-pushed the codex/fix-cli-owned-auth-gate branch from cae3f55 to d849849 Compare June 19, 2026 00:46
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 19, 2026
@vincentkoc
vincentkoc force-pushed the codex/fix-cli-owned-auth-gate branch from d849849 to 05ede48 Compare June 19, 2026 01:26
@openclaw-barnacle openclaw-barnacle Bot added size: M and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. size: S labels Jun 19, 2026
@vincentkoc
vincentkoc force-pushed the codex/fix-cli-owned-auth-gate branch from 86a2377 to 07cc2d0 Compare June 19, 2026 01:32
@vincentkoc

Copy link
Copy Markdown
Member

Clownfish 🐠 reef update

Thanks for the work here. Clownfish patched this branch directly so the contributor trail stays right where it started.

Source PR: #88551
Validation: pnpm test src/agents/command/attempt-execution.cli.test.ts src/agents/model-fallback.test.ts; pnpm check:changed
The contributor trail stays intact here: branch history, PR context, and changelog credit all still point back to this work.

fish notes: model gpt-5.5, reasoning medium; reviewed against 07cc2d0.

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 19, 2026
@vincentkoc
vincentkoc merged commit 20dd2be into openclaw:main Jun 19, 2026
175 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 19, 2026
* fix(agents): skip fallback auth gate for CLI runtimes

* fix(agents): skip auth gate for CLI-owned transport

* fix(agents): skip auth gate for CLI-owned transport

---------

Co-authored-by: openclaw-clownfish[bot] <280122609+openclaw-clownfish[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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.

3 participants