refactor(agents): carry resolved model runtime through auth#85373
refactor(agents): carry resolved model runtime through auth#85373dutifulbob wants to merge 3 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed June 1, 2026, 12:08 PM ET / 16:08 UTC. Summary PR surface: Source +339, Tests +249. Total +588 across 21 files. Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Review detailsBest possible solution: Retry the Codex review after fixing the execution failure. Do we have a high-confidence way to reproduce the issue? Unclear. The review failed before ClawSweeper could establish a reproduction path. Is this the best way to solve the issue? Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction. AGENTS.md: unclear because the file could not be read completely. Codex review notes: model gpt-5.5, reasoning high; reviewed against 6668eb82258c. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +339, Tests +249. Total +588 across 21 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Clockwork Review Wisp Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
714e9c3 to
25fa46f
Compare
|
Final draft implementation report for head Implemented the resolved model runtime path end to end: model resolution now returns a runtime descriptor; embedded runs and compaction carry that descriptor through auth, runtime auth updates, stream setup, and runtime planning; shared model auth derives selected-model runtime facts for callers without an explicit descriptor; provider stream lookup can use the selected model API owner; Ollama selected-model Validation run:
Current PR checks: latest Real behavior proof passes, workflow sanity/security/socket/lightweight checks pass or skip as expected for a draft PR. No inline review comments are open. The PR remains draft for maintainer/owner review of the additive provider auth hook context fields. Not covered here: full remote |
70c2fdb to
4e87c9e
Compare
|
@clawsweeper re-review This PR is now rebased onto current Latest head: Latest post-rebase validation:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
This comment was marked as spam.
This comment was marked as spam.
4e87c9e to
6409cf4
Compare
|
Rebased this PR onto current New head: Post-rebase local validation:
Notes from the rebase: the old |
Opened on behalf of Onur Solmaz (@osolmaz). Ready for maintainer review.
AI-assisted implementation requested by a maintainer.
Summary
Carry the resolved model runtime through the embedded agent path.
This is a follow-up to #80488. That PR fixed the narrow transport-aware per-model override path; this PR handles the more general runtime/plugin-owned path by keeping the selected provider, final model API/base URL, provider refs that own auth/stream hooks, and runtime plan together after model resolution. Later auth, stream setup, compaction, and runtime planning use those resolved facts instead of deriving them again from provider/model strings.
Refs #80487. Follow-up to #80488.
What Changed
baseUrloverride providerbaseUrl.Testing
Latest after rebasing onto current
upstream/main:node scripts/run-vitest.mjs src/plugins/provider-runtime.test.ts extensions/ollama/src/stream.test.ts extensions/ollama/index.test.ts src/agents/model-auth.test.ts src/agents/pi-embedded-runner/model.test.ts src/agents/pi-embedded-runner/run/auth-controller.test.ts src/plugins/provider-runtime.synthetic-auth-discovery.test.ts src/agents/pi-embedded-runner/compact.hooks.test.ts src/agents/pi-embedded-runner/compaction-runtime-context.test.ts- passed, 14 files / 510 tests.git diff --check- passed.node --import tsx scripts/check-import-cycles.ts- passed, 0 runtime value cycles.Earlier validation on the same implementation before the final rebase:
node scripts/run-vitest.mjs src/agents/model-auth.test.ts src/agents/pi-embedded-runner/compact.hooks.test.ts- passed, 4 files / 200 tests after the shared-auth fallback and compaction follow-through fix.node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo- passed.node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core-test.tsbuildinfo- passed.node scripts/run-tsgo.mjs -p tsconfig.extensions.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions.tsbuildinfo- passed.node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test.tsbuildinfo- passed.pnpm exec oxfmt --check extensions/ollama/index.test.ts extensions/ollama/index.ts extensions/ollama/provider-discovery.ts extensions/ollama/src/discovery-shared.ts extensions/ollama/src/stream.test.ts extensions/ollama/src/stream.ts src/agents/model-auth.test.ts src/agents/model-auth.ts src/agents/pi-embedded-runner/compact.hooks.harness.ts src/agents/pi-embedded-runner/compact.ts src/agents/pi-embedded-runner/model.test.ts src/agents/pi-embedded-runner/model.ts src/agents/pi-embedded-runner/resolved-model-runtime.ts src/agents/pi-embedded-runner/run.ts src/agents/pi-embedded-runner/run/auth-controller.test.ts src/agents/pi-embedded-runner/run/auth-controller.ts src/agents/resolved-model-runtime.types.ts src/plugins/provider-external-auth.types.ts src/plugins/provider-runtime.test.ts src/plugins/provider-runtime.ts src/plugins/types.ts- passed.OPENCLAW_LIVE_TEST=1 OPENCLAW_LIVE_OLLAMA=1 OPENCLAW_LIVE_OLLAMA_MODEL=qwen2.5:3b OPENCLAW_LIVE_OLLAMA_WEB_SEARCH=0 node scripts/run-vitest.mjs --config test/vitest/vitest.live.config.ts extensions/ollama/ollama.live.test.ts -t "runs native chat"- passed, 1 live test / 3 skipped by filter.codex review --base upstream/main- passed after fixing the review finding about callers that resolve model auth without an explicit runtime descriptor.Real behavior proof
Behavior addressed: custom/router-backed model selections now carry the final resolved transport/auth/stream facts into auth, stream setup, compaction, and runtime planning. A provider default no longer stands in for a per-model runtime choice.
Real environment tested: local source checkout with Node 22, repo dependencies installed, and local Ollama serving
qwen2.5:3bathttp://127.0.0.1:11434. No external provider secrets were printed or committed.Exact steps or command run after this patch: created a temporary
openclaw.jsonwheremodels.providers.custom-routerhad provider-levelapi: "openai-completions"andbaseUrl: "https://router.invalid/v1", while selected modelcustom-router/qwen2.5:3bhad model-levelapi: "ollama"andbaseUrl: "http://127.0.0.1:11434"; then ran:Evidence after fix:
{ "ok": true, "capability": "model.run", "transport": "local", "provider": "custom-router", "model": "qwen2.5:3b", "attempts": [], "outputs": [ { "text": "pong", "mediaUrl": null } ] }Observed result after fix: OpenClaw kept the visible selected provider/model as
custom-router/qwen2.5:3b, but used the selected model's native Ollama API/base URL for the actual local run. The inert provider-level router URL was not used, and the command returnedok: truewith the local model response.What was not tested: full remote
pnpm check:changedproof is blocked in this environment because Blacksmith Testbox is unavailable (blacksmithCLI missing) and direct AWS Crabbox has no usable AWS credentials/IMDS identity. Live Anthropic, Google, and OpenAI auth-profile smokes were not run in this local pass.Risks