v3.38.8 — provider/model config propagation fix (#2962)
- determineAgentModel() treats any non-alias config.model string as an explicit selection via the modelId fast-path
- agent_spawn forwards config.provider into the stored agent record for unambiguous explicit choices (ollama/openrouter)
- callAnthropicMessages() now consults persisted agents.providers config for baseUrl/apiKey/model when env vars are absent
- executeAgentTask() forwards the agent's explicit provider into the first dispatch call
- provider/model resolution now follows precedence: explicit per-agent flag → env vars → persisted agents.providers config → key-presence inference
- explicit provider/model config now propagates into agent execution instead of silently falling back to env vars or defaults
Highlights
- fix(agent): explicit provider/model config now propagates into agent execution (#2962, PR #3007)
providers configure and agent spawn --provider/--model previously persisted user intent but the execution path (callAnthropicMessages, executeAgentTask, determineAgentModel) only ever consulted env vars and a fixed 5-alias model list — silently discarding both. A user who configured local Ollama or OpenRouter would see two successful CLI commands, then execution would either fail closed or silently use a different provider/model than requested.
determineAgentModel()now treats any non-aliasconfig.modelstring (e.g. an Ollama tag) as an explicit selection via the existingmodelIdfast-path, instead of falling through to task-based routing / agent-type defaults.agent_spawnforwardsconfig.providerinto the stored (and returned) agent record when it's an unambiguous explicit choice (ollama/openrouter;anthropicis excluded since the CLI silently defaults to it when--providerisn't passed).callAnthropicMessages()now consults the persistedagents.providersconfig forbaseUrl/apiKey/modelwhen env vars are absent. A self-hosted, unauthenticated Ollama endpoint no longer requires the undocumentedOLLAMA_API_KEY=localsentinel.executeAgentTask()forwards the agent's explicit provider into the first dispatch call.
Precedence (resolving the open design question from the issue thread, credit @pacphi): explicit per-agent flag → env vars → persisted agents.providers config → key-presence inference (unchanged, last resort).
Regression coverage: v3/@claude-flow/cli/__tests__/agent-provider-model-propagation.test.ts (3 tests, each verified to fail against the pre-fix code and pass against the fix).
Verification
- TypeScript clean (
tsc --noEmit) - 202/209 existing tests green for touched files (7 pre-existing unrelated failures confirmed present on unpatched
maintoo — stalefsmock inmcp-tools-deep.test.ts) - CI: 107 checks passed, 3 skipped (conditional), 0 failed
- Tarball-verified: fix present in the published
@claude-flow/cli@3.38.8package