Repository navigation
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 4, 2026, 7:25 PM ET / 23:25 UTC. ClawSweeper reviewWhat this changesThe branch passes an embeddings-specific route into memory credential resolution so OpenAI OAuth is rejected before a remote vector request is made. Merge readinessKeep this PR open: it is a focused, correct repair for the linked credential-boundary bug, with no blocking patch finding. It intentionally makes OAuth-only OpenAI embeddings fail locally instead of sending that credential to a configured endpoint. Priority: P1 Review scores
Verification
How this fits togetherMemory search asks the bundled OpenAI provider to create query and document embeddings. The shared remote client chooses credentials and headers before sending the request to the configured embeddings endpoint. flowchart LR
A[Memory search] --> B[OpenAI embedding provider]
B --> C[Shared remote client]
C --> D[Credential route check]
D --> E[Request headers]
E --> F[Embeddings endpoint]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +3, Tests +36. Total +39 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the caller-level route declaration after normal exact-head checks, retaining the existing explicit remote-key path and the API-key fallback for configured OpenAI-compatible endpoints. Do we have a high-confidence way to reproduce the issue? Yes. The PR body provides an exact-head capture-server path through the real OpenAI embedding provider, with before, blocked-after, and API-key-after outcomes; source inspection independently confirms the missing route argument on current main. Is this the best way to solve the issue? Yes. The embedding client is the owner that knows it will call the embeddings endpoint, while changing the global undefined-route rule would incorrectly affect callers whose route is genuinely unknown. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against fb81d03d8eb2. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
6f322d7 to
21b573e
Compare
21b573e to
67f1f7b
Compare
|
Rebased onto @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Hey @Patrick-Erichsen I see that your assigned to this Pull Request would it be possible for a review or a possible merge? Thanks! |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
Closing due to inactivity. |
Fixes #111985
What Problem This Solves
Memory embeddings resolve provider auth without declaring which OpenAI API route they are about to use, so the auth-mode guard that keeps ChatGPT subscription credentials off the plain OpenAI Platform REST routes never runs. A ChatGPT OAuth profile is accepted for
/v1/embeddings, and the access token is sent as the bearer to whatevermodels.providers.openai.baseUrlpoints at.directOpenAIPlatformModelRequiresApiKeyinsrc/agents/model-auth-openai.ts:8only fires whenmodelApiis defined:packages/memory-host-sdk/src/host/embeddings-remote-client.ts:54calledresolveApiKeyForProviderwithout one, so bothassertAuthModeAllowedForModeland theisAuthModeAllowedForModelenv-credential branch atsrc/agents/model-auth-provider.ts:232short-circuited to allowed:Three things widen the blast radius. Memory is on by default and embeddings fire on session start with no memory config at all. The credential was never handed to OpenClaw:
src/agents/cli-credentials.ts:175deliberately resolvesCODEX_HOMEagainst the OS home rather than the OpenClaw state dir, so even isolated instances pick up an already-logged-in Codex CLI. And a custom OpenAI-compatiblebaseUrlis a normal configuration.Why This Change Was Made
The route is known at the call site, so the call site should declare it. This is the same shape as the already-landed OpenAI audio fix (#90793), which introduced
OPENAI_AUDIO_TRANSCRIPTIONS_APIand passes it asmodelApifromsrc/media-understanding/openai-compatible-audio.ts:47for exactly this reason.Loosening the guard instead (treating undefined
modelApias "platform route") was rejected: callers that legitimately resolve OpenAI auth without a known route, including the multi-route path insrc/agents/simple-completion-runtime.ts:292, would start failing closed for valid Codex subscription credentials.An earlier revision of this PR also declared
OPENAI_IMAGES_APIin the shared OpenAI-compatible image factory. That has been removed, per the ClawSweeper P1 onsrc/image-generation/openai-compatible-image-provider.ts. Two reasons, and the second is the stronger one:normalizeProviderId(provider) === "openai", andnormalizeProviderIdis plain lowercasing (packages/model-catalog-core/src/provider-id.ts:6). Every in-repo caller ofcreateOpenAiCompatibleImageGenerationProviderpasses a different id:litellm,deepinfra,xai. The bundledopenaiimage provider does not use that factory at all; it is a separate implementation inextensions/openai/image-generation-provider.tsthat owns its own Codex-Responses OAuth branch. So the declaration was dead code on every real path, and dead code that points at the wrong owner boundary.This PR is therefore scoped to the embeddings route the issue reports. Other capability call sites that resolve OpenAI auth (media understanding, TTS, image, plugin providers) are out of scope here; each owns its own route knowledge, and none of them is the path in #111985.
The api id follows the existing convention that these values name the wire dialect rather than the vendor:
openai-compatible-audio.ts:47usesOPENAI_AUDIO_TRANSCRIPTIONS_APIfor every OpenAI-compatible audio provider, not onlyopenai.User Impact
An operator whose only OpenAI credential is a ChatGPT/Codex login, and who points
models.providers.openai.baseUrlat any OpenAI-compatible endpoint (the repo's own comments name Requesty), no longer leaks that token to the third party on session start. The embeddings path now fails closed with the same guidance the model path already produces, and memory falls back the way it does for any other missing embeddings credential.Operators who supply an API key by any documented route (
OPENAI_API_KEY,models.providers.openai.apiKey,memory.search.remote.apiKey, or an api-key auth profile) are unaffected. Image generation is untouched by this revision.Evidence
Re-run at the current head after rebasing onto
main.67f1f7b9c15eabb8bf505dc1cb9295d92683da30main:fb81d03d8ebd(fix(commands): restore tool inventory for dynamic models (#119306))Driven through the real production entry point: the bundled OpenAI plugin's memory embedding provider,
createOpenAiEmbeddingProvider(extensions/openai/embedding-provider.ts:48), callingembedQuery. No mocks and no stubs. The only substitution is the endpoint the operator configures, which is a local HTTP server that records theAuthorizationheader it receives.Setup, identical across all three runs: an isolated
OPENCLAW_HOMEandOPENCLAW_STATE_DIR, a ChatGPT OAuth profile written into the real SQLite auth store through the productionsaveAuthProfileStore, andmodels.providers.openai.baseUrlpointed athttp://127.0.0.1:19556/v1. Token values are canaries, not real credentials.The driver is reproduced in full below so this is independently runnable rather than described.
1. Before, pristine
mainatfb81d03d8ebd, no API keyThe subscription token is sent to the configured third-party host and the call succeeds.
2. After, this branch, no API key
Zero outbound requests. The failure names the supported alternative rather than dead-ending.
3. After, this branch, same OAuth profile plus an API key present
This is the upgrade path for the
merge-risk: compatibilityconcern: an operator who currently relies on the OAuth-only path adds a documented API key and keeps working through the same embeddings route.The api-key credential is selected over the incompatible OAuth profile, the request goes out, and the OAuth token never appears on the wire.
Proof driver (
repro-111985.mts, untracked, run from the worktree root)Isolating both
OPENCLAW_HOMEandOPENCLAW_STATE_DIRmatters: without the second one the auth store resolves to the operator's real~/.openclaw/agents/mainand can abort on a pending legacy migration.Validation
oxlintis clean on both changed files. The colocated regression asserts the embeddings client forwardsmodelApi; the guard behavior it unlocks is already covered bysrc/agents/model-auth.profiles.test.ts.Not covered: no live request to
api.openai.com, since the capture server stands in for the configured endpoint, and no full build. The driver above is untracked and is not part of this diff.