Repository navigation
fix(agents): keep Daybreak access across OAuth token refresh - #184364
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesPreserve discovered Daybreak capabilities after OAuth token rotation when the provider confirms the same account and user. Example: User user-a in account-a selects daybreak_blue, then their OAuth access token, refresh token, and expiry rotate.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current-main OAuth-refresh failure while preserving account and dispatch authority; no actionable defects were found. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe embedded agent's Access guard combines the selected credential, account catalog, model route, and runtime authority to admit or reject provider requests immediately before transport. flowchart TD
A[Selected OAuth credential] --> C[Embedded Access guard]
B[Discovered account capabilities] --> C
D[Provider account matcher] --> C
E[Current runtime and account authority] --> C
C --> F[Guarded HTTP transport]
F --> G[Provider response]
Technical reviewBest possible solution: Use the existing provider identity matcher for refreshed discovery evidence while retaining catalog authority and final-request checks. Do we have a high-confidence way to reproduce the issue? Current main's exact-credential comparison exposes the failure directly, and the supplied baseline-versus-candidate transport results isolate token rotation; this review executed no target code. Is this the best way to solve the issue? The patch is the smallest complete repair: identity remains provider-owned, capability evidence remains catalog-owned, and no new cache, persistence format, or competing admission path is introduced. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 93414de2a86c. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +29, Tests +160. Total +189 across 2 files. Added test files: 1. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 26, 2026, 6:48 AM ET / 10:48 UTC (Revision 5). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Provide required OAuth mode and display-label fields instead of casting an incomplete catalog-auth fixture. Co-authored-by: VACInc <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…w#184364) * fix(agents): keep Daybreak access across OAuth token refresh * fix: bind refreshed access-program evidence to provider user identity * test(agents): load access guard provider through public facade * test(agents): complete access guard catalog auth fixture Provide required OAuth mode and display-label fields instead of casting an incomplete catalog-auth fixture. Co-authored-by: VACInc <[email protected]> --------- Co-authored-by: VACInc <[email protected]> Co-authored-by: roboclaw-bot <[email protected]>
Summary
High Level TLDR
Selecting Blue should work with both the
openclawandcodexruntimes inside OpenClaw. This PR fixes the native runtime rejecting a still-valid account capability after OAuth refresh. The Codex integration already forwards and validates the selection correctly. Real Gateway sessions now verify both paths, including a server-enforced negative control.Root Cause
prepareEmbeddedAccessProgramGuardcompared the credential captured by shared model discovery with the selected credential using deep equality. OAuth refresh changes access/refresh tokens and expiry while retaining the same account. The private account catalog can be cold after that change, so rejecting the shared discovery snapshot removes the evidence for the selected program and raisesOPENAI_ACCESS_PROGRAM_UNAVAILABLEbefore inference.The fallback now accepts refreshed OAuth credentials only when provider, enterprise URL, issuer, client ID and auth flow match, and the prepared provider's canonical
matchesPersonalAccountconfirms the same user and account. Matching a workspace alone is insufficient. Missing identity fails closed. Non-OAuth credentials retain exact equality. A published private catalog, including an empty one, remains authoritative. Dispatch still checks current runtime/account ownership.The regression tests use the real OpenAI provider through its public facade and the real prepared-account catalog. The facade loader also fixes this PR's
check-planfailure: a direct plugin import had pulled bundled extension sources into the core TypeScript graph.Verification
Real behavior proof
Built PR runtime:
85599ab6d1321353703e2e088aa609b872a70e21, OpenClaw2026.10.7; Codex CLI0.164.0. Linux, isolated loopback Gateway and state, existing ChatGPT subscription credentials, tools disabled. No production deployment. Final heade3d9538e738c54ebb77251ce1f063b878f5814a7changes only the test's plugin-loading boundary; the runtime code is identical to the live-tested build.The test used OpenClaw's supported
sessions.createandagentGateway methods, not standalone Codex and not a model-level payload override. For each case, create a fresh session withagentRuntimeset to the tested runtime andcyberAccessProgramset to the tested program. Run a prompt requesting exactlyBLUE_INTEGRATION_OK, then check the final result and actualmeta.agentMeta.agentHarnessId.codexBLUE_INTEGRATION_OKcodexBLUE_INTEGRATION_OKopenclawBLUE_INTEGRATION_OKopenclawBLUE_INTEGRATION_OKgpt-daybreak-blue-latestcodexBLUE_INTEGRATION_OKgpt-daybreak-blue-latestcodexselectedThe Daybreak Blue model requires access_programs.cyber=daybreak_blue.gpt-daybreak-blue-latestopenclawBLUE_INTEGRATION_OKgpt-daybreak-blue-latestopenclawselectedReproduction against an isolated, authenticated Gateway, replacing the uppercase placeholders with fresh session/idempotency identifiers and the test runtime/program:
Use runtime
codexoropenclaw, programdaybreak_blueorstandard, and the isolated Gateway's config/state environment. Positive results identify the requested runtime and selected model with no model fallback. The dedicated-model negative control proves that Blue reaches the backend through each OpenClaw integration. Redacted native wire capture also showsaccess_programs.cyber=daybreak_blueon the outgoing request.A successful ChatGPT-backend response can echo
access_programs.cyber=standardeven for this Blue-only model. That echo alone is not evidence of a downgrade: explicit Standard is rejected while explicit Blue completes. This replaces the earlier, unproven server-downgrade diagnosis.Automated checks
60 tests pass across five files:
Coverage includes refreshed same-user credentials, rejection of other users/accounts or missing identity, dispatch-time revocation, Codex account/catalog admission at the physical
turn/startwriter, typed program forwarding, and native Responses serialization.node --import ./scripts/tsx.mjs scripts/check-tsgo-core-boundary.mtspasses after the facade-loading correction. Targeted formatting/lint andgit diff --checkpass. The previous head's failingcheck-planwas traced to this test's direct plugin import; no CI status from that head is claimed as current-head proof.What was not tested
Additional real-transport proof
Verified 2026-10-26 against published head
01e44798f74a332fefd34a0afddc23c758866e4a. This head fixes the incomplete catalog-auth test fixture; production guard code remains identical to the earlier live Gateway build.This closes the transport-observation gap in the prior review. The probe composes the real OpenAI provider matcher, prepared account catalog, embedded Access guard, request-authority context, guarded fetch, DNS pinning, and default production HTTP transport with a disposable recording HTTP server. There is no mocked fetch, dispatcher, account matcher, or account-catalog owner. The recording server independently counts TCP connections and HTTP requests and verifies that the received synthetic credential and serialized Blue request match the selected input.
Only the local fixture hostname is explicitly allowed for this probe. Real DNS lookup completes before the revocation/reassignment triggers; the production final-request authority check then prevents the connection. Every server and port claim was closed/released after its case.
OPENAI_ACCESS_PROGRAM_UNAVAILABLEOPENAI_ACCESS_PROGRAM_UNAVAILABLEOPENAI_ACCESS_PROGRAM_UNAVAILABLEOPENAI_ACCESS_PROGRAM_UNAVAILABLEOPENAI_ACCESS_PROGRAM_UNAVAILABLERed/green: the same success assertion fails on the original guard specifically for rotated credentials (unchanged-credential control passes), then all six scenarios pass with the published guard. Baseline guard bytes come unchanged from
80ed71747c783a099fa14fc175a8d30c5123cb4d, Git blobb680ba4767a1c84cb6f5875d0569f826df4a361d, composed with the same candidate runtime dependencies to isolate the repaired boundary. This is not claimed as a whole-baseline Gateway run. The fixed probe completed in 7.47 seconds including runner setup; test duration was 5.23 seconds.Limits: credentials and the recording provider are synthetic. This proves the changed admission boundary and actual transport/no-transport outcomes, not an OAuth issuer refresh transaction or another live ChatGPT inference. The earlier real Gateway/ChatGPT runs above supply the independent integration/inference evidence. No production state or credentials were changed.
Reproducible transport probe
Save the TypeScript below as
src/agents/embedded-agent-runner/run/access-program.transport-proof.test.tsin a disposable checkout of the published head. Its SHA-256 is84521925be07c71c08dc8b9df6ab6e1b2083c47419ba1cf2bbc2876c8b1fb519.