Skip to content

fix(agents): fail stalled provider authentication at the run deadline - #189144

Merged
roboclaw-bot merged 3 commits into
mainfrom
loop/contributor-pr-93952
Oct 31, 2026
Merged

roboclaw-bot merged 3 commits into
mainfrom
loop/contributor-pr-93952

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Supersedes #93952, thanks @amittell.

What Problem This Solves

Fixes agent runs that hang indefinitely when provider credential lookup or a runtime token exchange never returns.

User Impact

Authentication stops at the existing run deadline or cancellation with an error naming the provider and auth step and suggesting a retry. Run deadline and cancellation errors cannot fall through to AWS sentinel handling or further auth attempts. Provider-originated abort errors retain their existing recovery before run expiry. No new settings or credential storage are introduced.

Exchange hooks receive an optional cancellation signal and should pass it to their transport. JavaScript cannot forcibly stop a plugin that ignores cancellation; its late result is still rejected before credential installation. Claimed durable OAuth refreshes retain their existing settlement owner.

Why This Change Was Made

The auth controller shares one startup budget across lookup and exchange, then consumes the existing execution owner's published deadline, respecting paused or unlimited execution when an auth step starts. An already-running exchange keeps the deadline captured at entry; later deadline extensions do not rearm its timeout. Request-time OAuth lookup and exchange use the same bound and request cancellation. Final teardown cancels auth; temporary cleanup for forwarded harness candidates keeps later API-key candidates usable.

The simplification pass removed the duplicate unavailable-reason adapter and a redundant missing-state check. Production growth is +126 net lines: the shared deadline/cancellation helper, execution-deadline projection and wiring, request-time propagation, and abort/error boundaries are required to close the complete flow. Existing parameter types moved to the existing type module to keep the controller within its file limit. No test-routing registry changed. The separate 159-line allocation covers only this change's regression growth.

Evidence

  • Baseline e1cd21501dd59366fefc3ff8263d97eeacdc799e: focused negative control failed 4 of 5 selected cases. Hung lookup, hung exchange and AWS exchange remained pending at 100 ms; cancellation incorrectly installed credentials. Slow success passed.
  • Replacement: all 88 focused tests passed across auth-controller.test.ts, auth-controller.binding.test.ts, auth-controller.request-auth.test.ts, and provider-runtime-auth.test.ts (70.48 s including compiled-worker preparation). New coverage includes slow success, one shared budget, request-time lookup/exchange deadlines, request-specific cancellation, late-result rejection, and forwarded harness candidate transitions, and provider-originated abort recovery. Existing durable OAuth settlement and account-authority tests pass.
  • The initial CI run identified four test cleanup callbacks returning Vitest utilities instead of void; the correction uses block bodies. Both affected files pass again: 52 tests in 19.81 s. The correction commit also has a clean P0–P2 autoreview; production source was unchanged by that cleanup correction. The final auth-signal simplification and added provider-abort regression were then validated by the complete 88-test run and a fresh full-candidate P0–P2 security review. Targeted type-aware oxlint, oxfmt, and git diff --check pass. Broad build/typecheck/test proof is delegated to this PR's CI; no broad suite ran on the production host.
  • Security-focused autoreview of the complete local candidate against the baseline above, P0–P2: scoped-clean. Fixed its findings about reset budgets, request-time lookup/cancellation, and temporary harness transitions. No provider or review configuration changed.
  • Contributor source was read only with gh pr view / gh pr diff; it was never checked out or executed. The contributor's Gateway traces support the original diagnosis, but no new Gateway or external-provider proof is claimed for this replacement. The Team Gateway was not modified or restarted.

Contributor credit: Alex Mittell [email protected], with Co-authored-by: Alex Mittell <[email protected]> on the replacement commit.

Share the existing run deadline across credential lookup and token exchange,
propagate cancellation, and reject late credentials before installation.

Co-authored-by: Alex Mittell <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 31, 2026 06:41
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: L labels Oct 31, 2026
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: dd22f4d299e071f9cabc1c0ad9e1d75d1d4d2fd9
  • Maintainer: @roboclaw-bot
  • Repository role: maintain

These security sensitive changes were made:

  • src/agents/embedded-agent-runner/run/auth-controller.request-auth.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/embedded-agent-runner/run/auth-controller.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/embedded-agent-runner/run/auth-controller.types.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/runtime-auth-refresh.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

roboclaw-bot and others added 2 commits October 31, 2026 06:47
Use the shared auth signal to distinguish run cancellation from a provider
AbortError, preserving existing recovery while terminating expired auth.

Co-authored-by: Alex Mittell <[email protected]>
@roboclaw-bot
roboclaw-bot enabled auto-merge (squash) October 31, 2026 06:53
@roboclaw-bot
roboclaw-bot merged commit 7bd53ff into main Oct 31, 2026
134 of 135 checks passed
@roboclaw-bot
roboclaw-bot deleted the loop/contributor-pr-93952 branch October 31, 2026 07:00
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 1, 2026
…openclaw#189144)

* fix(agents): fail stalled provider authentication at the run deadline

Share the existing run deadline across credential lookup and token exchange,
propagate cancellation, and reject late credentials before installation.

Co-authored-by: Alex Mittell <[email protected]>

* fix(tests): return void from auth cleanup callbacks

Co-authored-by: Alex Mittell <[email protected]>

* fix(agents): preserve provider abort recovery before run expiry

Use the shared auth signal to distinguish run cancellation from a provider
AbortError, preserving existing recovery while terminating expired auth.

Co-authored-by: Alex Mittell <[email protected]>

---------

Co-authored-by: Alex Mittell <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Share the current execution deadline across credential resolution and token exchange, propagate cancellation, and reject late credentials before installation. Preserve durable refresh settlement, current authority checks and provider-abort recovery. Scoped self-review complete.

Proof: source regression fails on baseline (still pending rather than AbortError); fixed auth-controller and binding suites pass. Typed lint and full live qualification remain pending.

(cherry picked from commit 7bd53ff)

Co-authored-by: Alex Mittell <[email protected]>

Co-authored-by: RomneyDa <[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 docs Improvements or additions to documentation security-sensitive-changed size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant