Repository navigation
refactor(media): consolidate automatic provider selection - #131534
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 12:48 AM ET / 04:48 UTC. ClawSweeper reviewWhat this changesThe PR moves automatic media-provider default-model and priority lookup into the provider registry and shares the runner’s provider-selection path while adding preservation coverage. Merge readinessKeep open. This member-authored, maintainer-labeled PR is a focused, net-negative refactor; no introduced correctness or security defect was found, and the exact-head check rollup is still incomplete. Priority: P3 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherMedia understanding selects an authenticated provider and model for image, audio, and video attachments before dispatching to the provider runtime and returning structured output to the agent. The registry supplies provider capabilities, default models, and automatic-selection priority. flowchart LR
A[Media attachments] --> B[Automatic media selection]
C[Active model or configured keys] --> B
D[Provider registry metadata] --> B
B --> E[Provider authentication]
E --> F[Media provider runtime]
F --> G[Structured media output]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -69, Tests +250. Total +181 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the single registry-owned lookup policy and land only after the exact PR-head checks complete successfully. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR refactors existing selection behavior rather than reporting a user-facing failure. Is this the best way to solve the issue? Yes. The registry already owns provider metadata, so moving pure default and priority lookup there removes duplicate policy without changing configuration or plugin contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cd7b282ed8c5. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
The cleanup is ready for native preparation at The latest ClawSweeper review found no defect and left two pre-merge items: finish exact-head checks and complete maintainer handling. The checks are now green and the independent maintainer review is complete. One evidence qualification: the older Whisper test does not establish executable competition because its fixture clears PATH; the PR body already records that gap. Our proof does not rely on that stronger interpretation. The registry owns priority/default lookup; the runner shares eligibility/authentication/model selection without changing active/key provider identity, model-read timing, configured image precedence, audio defaults, or local-audio fallback ordering. Production is +80/-149, net 69 lines removed; preservation tests are +250/-0. No public SDK, configuration, protocol, storage or dependency contract changes. Verification used fresh independent baseline/candidate installs on Linux Node24.19.0 and pnpm11.22.0 in clean-machine run33138443444. Actual source commands included: node scripts/run-vitest.mjs src/media-understanding/defaults.test.ts src/media-understanding/runner.auto-selection.test.ts src/media-understanding/provider-registry.test.ts src/media-understanding/runner.auto-audio.test.ts src/media-understanding/runner.vision-skip.test.ts src/media-understanding/runner.video.test.ts --maxWorkers=2 --reporter=default --reporter=json --outputFile=<owned-evidence>/vitest.json
node scripts/check-changed.mjs --timed --base origin/main --staged
pnpm plugin-sdk:check-exports
pnpm plugin-sdk:surface:check
pnpm buildBoth sides passed88/88 preservation tests and all15 normal build stages; candidate passed all28 changed-file stages and both SDK guards. Real built audio/video CLI and public image SDK calls preserved parsed requests and fresh outputs. An independent source-blind validator passed12 outcomes, and all69 reachable emitted declarations were byte-identical with separately checked AST import closure. Owned processes, proof trees and lease were cleaned up. The five-file patch also composes unchanged with current main through Proof limits remain explicit: owned loopback endpoints prove routing/transport/output, not external-provider availability or recognition quality. The initial missing-FFmpeg attempt and initial validator-stdout framing failure are retained as failed attempts; their separate corrections did not alter product source. The older competing-Whisper PATH fixture weakness and single-caller private forwarder remain named follow-ups in the PR body. No merge is claimed yet. |
|
Merged via squash.
|
What Problem This Solves
Media auto-selection duplicated its provider priority/default-model policy between the configuration defaults and the runtime runner. Active-model selection and API-key selection also repeated the same eligibility, authentication, and model-resolution flow. Those copies made behavior-preserving maintenance unnecessarily error-prone.
Why This Change Was Made
The existing provider registry becomes the single owner of registry-only priority and default-model lookup. The runner shares its provider eligibility/authentication/model-selection flow; configuration and manifest caching remain in the defaults owner. No new abstraction layer, dependency, configuration key, protocol, schema version, or public SDK export is introduced.
The two callers deliberately retain different timing and identity contracts: active selection normalizes its execution provider and reads the model after authentication; key selection retains its trimmed provider identity and captures its model before authentication. Audio still uses its provider default rather than the chat model, and the final key-provider pass after unavailable local audio remains intact.
Production LOC: +80/-149 (net -69). Preservation tests: +250/-0. Pure moves cancel in that count.
User Impact
No intended user-visible change. Existing media selection, configured-image insertion, regional provider aliases, priority ordering, native-vision bypass, authentication, and operator output are preserved. This is an internal cleanup; no changelog entry is needed.
Evidence
9aeedbac84660851602d233b7af1a0233603957f: 161 passed jobs, 18 intentional skips, requiredopenclaw/ci-gatepassed. All three pre-commit Codex review passes and all three separate published-head passes finished with no actionable findings. Source, index, patch and review-runtime cleanup were independently checked.The first environment attempt lacked FFmpeg; installation and a separately recorded rerun resolved it without changing product source. The first independent validator misparsed ordinary SDK diagnostic stdout; only its own result framing was corrected before the successful run. Both failed attempts remain recorded as failures. Existing dependency build warnings were not suppressed.
Current-main composition through
7573b91727c8f9acb0c1ee611749698b92181436is conflict-free and retains the exact five-file patch and afterimages. Native preparation, merge and actual-squash/ancestry verification remain separate steps; this text does not claim the PR is merged.Named Follow-ups
The existing auto-audio test titled “prefers provider keys over auto-detected local whisper” sets its mock-binary PATH outside a fixture that clears PATH. It does not actually prove a competing local binary is available; fixing that fixture and asserting discoverability is separate follow-up work. The new final-key-pass case tests unavailable local audio and makes no competing-binary claim. A private single-caller forwarding helper in
runner.entries.tscan also be removed separately. Neither is included in this change's line count.