Skip to content

fix(memory): restore embeddings with Codex OAuth - #160878

Merged
Patrick-Erichsen merged 2 commits into
openclaw:mainfrom
astra-openclaw:fix/memory-codex-oauth
Oct 2, 2026
Merged

Patrick-Erichsen merged 2 commits into
openclaw:mainfrom
astra-openclaw:fix/memory-codex-oauth

Conversation

@astra-openclaw

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes memory search failing with No API key found for provider "openai" after an update when the configured Codex OAuth account already has working embedding access.

Related: #159920.

User Impact

Eligible accounts can continue using their existing OpenClaw-stored Codex OAuth profile for memory indexing and semantic search. No configuration change or reauthentication is required. Embedding access remains subject to the account's permissions.

Why This Change Was Made

The embedding capability filter rejects ordinary Codex OAuth before sending a request, even when the endpoint accepts that credential. Exempt Codex OAuth from that API-key-only check while preserving the separate Sign in with ChatGPT token-sharing and identity-only grant restrictions, native static-token rejection, and model-route compatibility checks. Update the existing credential-selection regression and the affected documentation.

Evidence

  • Reproduced through openclaw memory status --deep: credential resolution failed before HTTP. The updated regression also failed on the original code, with the other 25 cases passing.
  • Live contract checks on September 28: native Codex and OpenClaw-stored OAuth credentials each returned HTTP 200 from /v1/embeddings for synthetic input, using text-embedding-3-small and returning one 1,536-dimensional vector. No credentials or private input are included here.
  • After rebuilding and restarting the gateway, memory status --deep reported a successful embedding probe, semantic search available, and valid index identity. A gateway tools.invoke call to memory_search returned three results with the expected OpenAI provider and embedding model.
  • Focused tests: 44 passed across embedding-provider.test.ts, provider-auth.contract.test.ts, and memory-embedding-adapter.test.ts. The standalone embedding file was checked again on September 29: 26 passed, 50.17 s Vitest duration / 52.15 s wrapper wall time. This changes an expectation in an existing case; no new fixture or test case is added. Approximately 15 s was test execution, with most remaining time in compilation/imports for the existing provider/auth integration fixture.
  • OpenAI plugin typecheck, targeted lint, formatting, and git diff --check passed. Auto Review completed with no actionable P0 findings.

The runtime and live checks used base 7526f600cf1. The PR was rebased onto 4ddd0e33973 to resolve one documentation-table conflict; the production and test files remain byte-identical to the validated fix. The newer authentication documentation was preserved with only the embedding/TTS row split. Full-repository suites were not run; these results do not claim current-head CI coverage.

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: openai size: XS labels Sep 29, 2026
@astra-openclaw
astra-openclaw marked this pull request as ready for review September 29, 2026 01:49
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. 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. labels Sep 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 8:36 PM ET / October 2, 2026, 00:36 UTC (Revision 3).

ClawSweeper review

What this changes

The OpenAI plugin allows eligible stored Codex OAuth credentials for memory embeddings, updates existing credential-selection coverage, and documents account-dependent access.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary: current main and the latest release still reject ordinary OAuth embedding credentials before HTTP. The focused repair has sufficient reported live proof, verified maintainer approval, and no actionable correctness findings.

Priority: P2
Reviewed head: a0cd646efc888b19ca9dd8d7b6305937ba072704

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful live observations, existing regression coverage, and no actionable patch findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Contributor-reported live output connects the changed OpenAI policy to successful native embeddings, a deep memory probe, and Gateway memory_search results after the fix. Production source is unchanged since the prior reviewed head; no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Contributor-reported live output connects the changed OpenAI policy to successful native embeddings, a deep memory probe, and Gateway memory_search results after the fix. Production source is unchanged since the prior reviewed head; no stored-data contract changes.
Evidence reviewed 8 items Verified introduced change: The pinned merge-base-to-head diff changes only embedding credential eligibility, an existing test expectation, and five documentation pages. SIWC, identity-only, native static-token, and explicit model-route restrictions remain intact.
Current main still needs the repair: Fetched main retains the unconditional API-key requirement for native embeddings, rejecting ordinary OAuth even when the account has upstream access.
Latest release comparison: The supplied latest release v2026.9.7 also contains the unconditional native embedding API-key restriction; this repair is not present there.
Findings None None.
Security None None.

How this fits together

Memory indexing and semantic search send text to an embedding provider. The OpenAI plugin selects compatible stored credentials before the shared HTTP client requests vectors used by memory search.

flowchart LR
 A[Memory text or search query] --> B[OpenAI embedding provider]
 C[Stored credentials] --> D[Credential eligibility policy]
 B --> D
 D -->|Compatible credential| E[Embedding HTTP request]
 D -->|Unsupported grant| F[Authentication error]
 E --> G[Vectors for memory search]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +3, Tests +4, Docs +4. Total +11 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 2 +3
Tests 1 4 0 +4
Docs 5 13 9 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 22 11 +11

Review metrics

Metric Value Why it matters
Credential-selection growth production +3 LOC, tests +4 LOC; 0 new test cases The predicate refinement preserves static-token rejection, and coverage extends an existing credential-selection case.

Technical review

Best possible solution:

Use the existing provider-owned policy to admit account-authorized OAuth embeddings while retaining unsupported-grant rejection and unchanged credential storage.

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

Yes, source inspection establishes that ordinary OAuth-only native embedding selection fails before HTTP on current main; the contributor also reports this through memory status --deep. This review did not execute target code.

Is this the best way to solve the issue?

Yes, refining the existing OpenAI credential policy is the narrowest repair and preserves the independently enforced grant and endpoint distinctions.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9a455598ddca.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs a bounded memory embedding authentication failure for eligible OAuth accounts.
  • merge-risk: 🚨 auth-provider: OAuth becomes eligible for native embedding requests; account-dependent access is explicitly accepted and separate unsupported grants remain rejected.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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): Contributor-reported live output connects the changed OpenAI policy to successful native embeddings, a deep memory probe, and Gateway memory_search results after the fix. Production source is unchanged since the prior reviewed head; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Contributor-reported live output connects the changed OpenAI policy to successful native embeddings, a deep memory probe, and Gateway memory_search results after the fix. Production source is unchanged since the prior reviewed head; no stored-data contract changes.

Evidence

What I checked:

  • Verified introduced change: The pinned merge-base-to-head diff changes only embedding credential eligibility, an existing test expectation, and five documentation pages. SIWC, identity-only, native static-token, and explicit model-route restrictions remain intact. (extensions/openai/model-auth-policy.ts:54, a0cd646efc88)
  • Current main still needs the repair: Fetched main retains the unconditional API-key requirement for native embeddings, rejecting ordinary OAuth even when the account has upstream access. (extensions/openai/model-auth-policy.ts:54, 9a455598ddca)
  • Latest release comparison: The supplied latest release v2026.9.7 also contains the unconditional native embedding API-key restriction; this repair is not present there. (extensions/openai/model-auth-policy.ts:54, c074824a27c9)
  • Production boundary and grant enforcement: The embedding provider passes capability=embedding to OpenClaw's shared resolver. The resolver checks grant compatibility before credential resolution and again afterward; destination ownership and guarded HTTP dispatch remain unchanged. This path does not execute or depend on the native Codex harness. (extensions/openai/embedding-provider.ts:72, a0cd646efc88)
  • After-fix live evidence: The captured PR body reports native /v1/embeddings HTTP 200 with a 1,536-dimensional vector, successful openclaw memory status --deep, and Gateway memory_search returning three results after rebuild and restart. These observations exercise the changed credential policy through the real memory flow; account entitlement remains provider-controlled. Body snapshot sourceRevision: 448883fc5db4798a965e52220f74cb896c7657fe880b648f87848508c994d6e6.
  • Accepted account-dependent behavior: Patrick-Erichsen explicitly approved stored Codex OAuth embedding access when the account grants it, while preserving SIWC, identity-only, static-token, and model-route restrictions: fix(memory): restore embeddings with Codex OAuth #160878 (comment). GitHub reports role_name=maintain. The comment records an 11-case source probe and acknowledges that independent OAuth HTTP repetition was unavailable.

Likely related people:

  • stevenlee-oai: Raw commit 1067523 adds extensions/openai/model-auth-policy.ts:20 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 106752303d73; files: extensions/openai/model-auth-policy.ts)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Patrick-Erichsen: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (2 earlier review cycles)
  • reviewed 2026-09-29T01:55:47.649Z sha 9035804 :: blocked before merge. :: none
  • reviewed 2026-10-01T23:50:39.590Z sha 9035804 :: needs maintainer review before merge. :: none

@Patrick-Erichsen

Patrick-Erichsen commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer decision: support stored Codex OAuth credentials for native OpenAI embeddings when the account grants access. Patrick approved this direction and landing; keep the separate SIWC token-sharing and identity-only rejection, native static-token rejection, and model-route compatibility checks.

This is an OpenClaw credential-selection decision. It does not claim that the Codex CLI itself implements embeddings or that every OAuth account has access.

Pre-merge verification for a0cd646efc888b19ca9dd8d7b6305937ba072704 (source tree identical to reviewed 9035804):

  • Own exact-source before/after probe passed all 11 cases against inspected main 4587ef9 and this head. Ordinary OAuth native embeddings changed from rejected to eligible. SIWC, identity-only OAuth, native static tokens, and incompatible explicit model routes remain rejected; API keys, custom static-token endpoints, image, and transcription behavior remain unchanged.
  • Fresh exact-head CI and required merge gate passed: CI run. Fresh Auto Review (gpt-5.6-sol, high, branch scope, default P0 priority) completed scoped-clean. Lead and independent source review found no concrete correctness blocker across priorities. Fresh ClawSweeper review has no before-merge actions or Rank-up moves.
  • Contributor-reported live proof: native /v1/embeddings HTTP 200 with 1536-dimensional output, successful deep memory probe, and Gateway memory_search returning three results. I could not independently repeat OAuth HTTP proof: both available native Codex sessions use API-key auth and have no OAuth access token. No operator auth or Gateway state was modified.
  • Direct Codex source inspection at 6be2a6ca952ac9f70676ce4dd07fda27175aa9dd: OAuth authorization, provider routing, and bearer authentication. These establish OAuth mechanics, not embedding entitlement or a native Codex embedding feature.
  • Root cause and owner: the existing OpenAI capability policy rejected ordinary OAuth before HTTP. This repair stays in that owner and preserves its grant distinctions. No paths removed, no config/schema or persisted-state changes. Production +3 lines, tests +4, docs +4; the predicate refinement is needed to preserve native static-token rejection rather than deleting the whole restriction.

CI follow-up: rerunning the Sep 29 workflow switched the fork job to GitHub-hosted execution with two compiler workers. Both package-boundary compile (126 plugins) and canary commands printed success, but the job exceeded its 20-minute budget and GitHub cancelled it. This is recorded as a fork-rerun capacity/budget follow-up, not an embeddings failure. An empty commit starts the normal CI path again without changing source or rewriting contributor history. The new normal CI run completed successfully, including the boundary check on its intended 32-vCPU runner and required openclaw/ci-gate. ClawSweeper revision 3 also reviewed the new head with no actionable findings or before-merge steps.

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Restart the normal CI path after the fork rerun used two compiler workers and exceeded the package-boundary job budget. No source changes.
@Patrick-Erichsen
Patrick-Erichsen merged commit f6883b3 into openclaw:main Oct 2, 2026
96 checks passed
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
* fix(memory): restore embeddings with Codex OAuth

* chore(ci): refresh embeddings validation

Restart the normal CI path after the fork rerun used two compiler workers and exceeded the package-boundary job budget. No source changes.

---------

Co-authored-by: astra-openclaw <[email protected]>
Co-authored-by: Patrick Erichsen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: openai 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. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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.

2 participants