Repository navigation
fix(ollama): resolve web search secret refs - #104829
vincentkoc merged 9 commits into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 5:55 AM ET / 09:55 UTC. ClawSweeper reviewWhat this changesThe PR makes Ollama web search resolve configured environment SecretRefs, reject unavailable explicit SecretRefs before a request, and retain ambient Merge readinessThis PR appears ready for normal maintainer merge review: the shared resolver now handles configured environment SecretRefs before Ollama selects its ambient credential, and the maintainer explicitly approved fail-closed precedence for unavailable explicit refs. The branch is currently reported mergeable but behind Priority: P2 Review scores
Verification
How this fits togetherOllama’s web-search plugin takes provider configuration plus environment state, resolves credentials before guarded HTTP requests, and returns search results to the agent tool. The shared resolver distinguishes explicit SecretRefs from ambient provider keys so operator configuration remains authoritative. flowchart LR
Config[Ollama provider configuration] --> Resolve[Shared credential resolution]
SecretRef[Environment SecretRef] --> Resolve
Ambient[Ambient OLLAMA API key] --> Resolve
Resolve --> Precedence[Explicit reference precedence]
Precedence --> Guarded[Guarded web-search request]
Guarded --> Results[Agent search results]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +31, Tests +185. Total +216 across 4 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Land the narrow resolver-and-plugin fix after refreshing the merge result against current Do we have a high-confidence way to reproduce the issue? Yes in source form: configure Is this the best way to solve the issue? Yes. Reusing the existing shared credential resolver while keeping Ollama-specific marker filtering and explicit-reference diagnostics in the owner plugin is narrower and safer than adding parallel Plugin SDK behavior. AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against f943a94a3303. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (22 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review Pushed exact head What changed:
Exact-head runtime proof:
Proof output: {
"head": "049435911000f746de1c6b40bc1504c22b56877f",
"successCount": 1,
"calls": [
{
"method": "POST",
"url": "/api/experimental/web_search",
"authorizationMatched": true,
"bodyHasQuery": true
}
],
"missingRefBlockedBeforeRequest": true,
"missingRefErrorMatched": true,
"nonEnvRefBlockedBeforeRequest": true,
"nonEnvRefErrorMatched": true
}Local validation on this patch:
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
7048ae4 to
28f39ca
Compare
|
Exact-head proof binding after the force-push (no new loopback rerun is claimed):
The separate maintainer decision about fail-closed compatibility remains open; this comment binds the existing runtime proof and does not present CI as loopback proof. |
|
Exact-head runtime proof is now refreshed for
This closes the exact-head runtime-proof gap only. The owner-level compatibility decision remains unresolved: whether an unavailable explicit |
Route configured models.providers.ollama.apiKey resolution through the existing shared resolveWebSearchProviderCredential helper so env-backed SecretRefs resolve for web search, and resolve the ambient OLLAMA_API_KEY independently of the configured selected-host key so mixed setups still reach the Ollama Cloud fallback after both selected-host attempts fail (regression fixed at web-search-provider.ts:195). Drop the two optional plugin-SDK resolver hooks (provider normalization and unavailable-configured-ref callback) added earlier: the fix does not depend on them, so the shared resolver and its generated plugin-SDK baseline stay identical to main and no new plugin-SDK contract surface is introduced. Ollama applies its own non-secret-marker filter locally on the resolver output instead. Add a mixed-credential regression test (configured host key plus a distinct ambient OLLAMA_API_KEY reaching the cloud fallback) and drop the tests for the removed fail-closed-throw behavior.
|
Maintainer decision: adopt fail-closed credential precedence. An explicitly configured SecretRef is authoritative; if it is unavailable or unsupported, Ollama web search must fail before any request even when ambient Ambient |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Maintainer decision: explicit configured SecretRef credentials remain authoritative and fail closed when unavailable; OpenClaw must not silently fall back to an ambient Ollama key. The release-owned CHANGELOG edit has been removed, focused tests and fresh autoreview are clean, and the prepared head is now published. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Exact-head public tool proof is now attached to the PR body for @clawsweeper re-review |
* origin/main: (1976 commits) fix(ollama): models advertise tools when /api/show fails (openclaw#109971) fix(ollama): use CJK-aware char estimate for usage fallback (openclaw#110073) fix(ollama): release failed setup response bodies before returning (openclaw#111802) feat(plugins): externalize Synthetic provider (openclaw#116720) fix(agents): unblock channel turns after restart recovery (openclaw#116728) fix(telegram): keep typing alive during active steered tasks (openclaw#116721) fix(gateway): admit standalone MCP app work (openclaw#116727) fix(googlechat): record canonical receipt thread (openclaw#116717) test(ui): cover the Talk relay start-stop race fix(ui): close superseded Talk allocations fix(agents): resume interrupted turns past progress commentary (openclaw#116725) fix(gateway): sign device proofs with challenge time (openclaw#116679) fix(testing): load relay smoke through UI Vite config test(testing): guard realtime relay smoke module path fix(testing): repair realtime relay live smoke import test: type session request parameters (openclaw#116713) fix: retain event invalidation for pagination docs: note queued session refresh fix fix: preserve queued session refresh options fix(exec): require approval for abbreviated inline eval flags [AI] (openclaw#116529) ...
|
Merged current @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
What Problem This Solves
Ollama web search did not resolve env-backed SecretRefs configured at
models.providers.ollama.apiKey. Treating an explicitly configured but unavailable SecretRef as no configuration could also select an unrelated ambientOLLAMA_API_KEYand route the query to Ollama Cloud.Why This Change Was Made
The Ollama runtime now delegates literal and env-backed SecretRef resolution to the existing shared
resolveWebSearchProviderCredential(...)helper. The plugin separately preserves whether the configured input was a SecretRef, so a missing or unsupported ref fails before any request without expanding the Plugin SDK. Literal configured keys and the independent ambient cloud key remain separate, preserving the selected-host attempts plus authenticated cloud fallback used by mixed setups.User Impact
Users can configure an env SecretRef for the Ollama provider key and have the resolved value sent on web-search requests. Missing or non-env SecretRefs fail before
fetchWithSsrFGuardinstead of silently using an unrelated ambient key. Existing marker-string fallback toOLLAMA_API_KEYand mixed configured-key/ambient-key cloud fallback remain covered.Evidence
Current PR diff is limited to
extensions/ollama/src/web-search-provider.tsandextensions/ollama/src/web-search-provider.test.ts; Plugin SDK, core credential helper, packages, and generated API baseline have zero diff.The configured-ref path calls the shared resolver, uses the public
coerceSecretRef(...)contract to retain explicit-ref state, and rejects an unavailable ref before request construction.Focused tests cover resolved env refs, missing env refs with an ambient key present, unsupported non-env refs, mixed literal configured and ambient keys, and marker-string fallback.## Proof
Exact current candidate head:
28f39ca2886ab1a3a42481f233612546b67abfa0.Secretless fork Actions run 29720026227 passed the exact-head public-provider runtime proof. The isolated runner unset repository, Actions runtime, package-registry, and OIDC tokens before candidate execution; anonymously fetched and checked out the full candidate SHA; installed the exact lockfile with pinned Node 24.15.0 and pnpm 11.2.2; and exercised the public
createOllamaWebSearchProvider().createTool().execute()path.The repo-supported mock-marked fetch transport retained fetch-guard URL/policy validation while redirecting dispatch to IPv4 loopback. No real provider credential or external provider endpoint was used. Redacted transcript:
openclaw/ci-gate, build artifacts, changed Node tests, production/test types, lint, extension package boundary, dependency guards, and security checks.models.providers.ollama.apiKeySecretRef should fail closed when ambientOLLAMA_API_KEYexists. This evidence does not claim the PR is otherwise cleared.Post-Rebase Proof Binding (2026-07-26)
The public Ollama provider runtime proof above ran on
28f39ca2886ab1a3a42481f233612546b67abfa0. It is bound to the rebased current head06b415c1e26c0291cb3a85a13c9555490014f9c1as follows:64c82812a5e52f4a03d2b89b8132c068a048a81b...28f39ca2886ab1a3a42481f233612546b67abfa00951d0dd307d5008276714679c62459293d3b619...06b415c1e26c0291cb3a85a13c9555490014f9c126968e2110c378ea3d58b2578802ea6a33622ec6+172/-8No new runtime execution is claimed. The binding shows that the contributor patch exercised by the prior public-provider proof is unchanged after rebase, while current-head CI validates its integration with the frozen main base. The documented owner-level compatibility decision remains unresolved.
Exact-Head Public Tool Proof (2026-07-31)
Maintainer proof ran on exact published head
00bd1a123a6224e9c648ca73b2eb5b155711ae8cthrough the publiccreateOllamaWebSearchProvider().createTool().execute()surface. Therepo-supported mocked guarded-fetch boundary used redacted fake credentials
and recorded request routing without external provider traffic.
The focused proof passed as one Vitest test on July 31, 2026. It confirms the
approved compatibility decision: an unavailable explicit SecretRef fails
closed instead of using ambient
OLLAMA_API_KEY, while a literal configuredselected-host key still preserves the independent ambient cloud fallback.