fix: respect user's model selection instead of forcing overrides#1050
fix: respect user's model selection instead of forcing overrides#1050srobinson wants to merge 1 commit intoruvnet:mainfrom
Conversation
Fixes ruvnet#1044 — user sets Sonnet 4.5 in Claude Code but claude-flow forces Opus 4.5. Three root causes: 1. Wrong Opus model ID: `claude-opus-4-20250514` doesn't exist, corrected to `claude-opus-4-5-20251101` 2. ANTHROPIC_MODEL env var unconditionally overwritten in executeClaudeCode(), ignoring any user-set value. Now only sets the env var when the user hasn't already configured one. 3. headless.ts runtime hardcoded `model: 'sonnet'` as a config override, stomping each worker's own model preference. Removed so workers use their configured model (or fall back to sonnet). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #1044 where users configure Sonnet 4.5 in Claude Code but claude-flow incorrectly forces Opus 4.5. The fix addresses three root causes: correcting an invalid Opus model ID, respecting user-set ANTHROPIC_MODEL environment variables, and removing hardcoded model overrides.
Changes:
- Fixed Opus model ID from non-existent
claude-opus-4-20250514toclaude-opus-4-5-20251101 - Modified environment variable handling to respect existing ANTHROPIC_MODEL values set by users
- Removed hardcoded
model: 'sonnet'override that was preventing workers from using their configured models
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| v3/@claude-flow/cli/src/services/headless-worker-executor.ts | Corrected Opus 4.5 model ID and added conditional logic to preserve user's ANTHROPIC_MODEL env var |
| v3/@claude-flow/cli/src/runtime/headless.ts | Removed hardcoded model parameter to allow workers to use their configured default models |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!env.ANTHROPIC_MODEL) { | ||
| env.ANTHROPIC_MODEL = MODEL_IDS[options.model]; | ||
| } |
There was a problem hiding this comment.
The logic for respecting the user's ANTHROPIC_MODEL environment variable is not covered by tests. Consider adding a test case that verifies:
- When ANTHROPIC_MODEL is already set in process.env, it should not be overridden
- When ANTHROPIC_MODEL is not set, it should default to the worker's configured model
This would help prevent regressions and document the intended behavior.
Live demo: used fmm to fix a bug in ruvnet/claude-flow (9,008 files). fmm init indexed 2,221 files in 3s, navigated straight to 2 files, 5-line fix, clean PR pushed without fmm artifacts. - Case study with diffs, metrics, workflow documentation - Social content: 5-tweet thread + short-form blog post PR: ruvnet/ruflo#1050 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* exp16: A/B cost experiment + fix dep_matches and .ts/.js priority Bug fixes: - dep_matches now resolves relative paths (../foo) against dependent file's directory instead of naive suffix matching. Fixes downstream dependents always returning empty. - Export index prefers .ts over .js when both export the same symbol, preventing non-deterministic race in parallel manifest generation. Experiment (exp16-cost): - Docker-isolated A/B: vanilla Claude vs Claude+fmm - 10 verifiable tasks with ground truth from fmm index - Result: fmm eliminates grep (-100%), fewer tools (-33%), but only -10% tokens — system prompt overhead drowns real navigation cost. - Proves Docker API approach insufficient; need CLI-based test. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Pivot to .fmm sidecar files, drop inline frontmatter Replace inline `// --- FMM ---` comment blocks with `.fmm` sidecar companion files (e.g., `foo.rs` → `foo.rs.fmm`). Sidecars use plain YAML, are independent of source file format, and don't pollute source. - Extractor writes sidecar files instead of prepending to source - CLI: remove `--manifest-only` flag, add `clean` subcommand - Formatter outputs YAML sidecar format instead of comment blocks - Manifest reads from sidecars, drops inline parsing - MCP serves sidecar-based data - Navigation skill rewritten for sidecar-first workflow - Fixtures and tests updated for new format - Remove obsolete docs (CLAUDE-SNIPPET.md, claude-skill.md) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add claude-flow #1044 case study — real-world fmm proof Live demo: used fmm to fix a bug in ruvnet/claude-flow (9,008 files). fmm init indexed 2,221 files in 3s, navigated straight to 2 files, 5-line fix, clean PR pushed without fmm artifacts. - Case study with diffs, metrics, workflow documentation - Social content: 5-tweet thread + short-form blog post PR: ruvnet/ruflo#1050 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add comprehensive research docs + fix score.py review issues 6 research docs: architecture, CLI reference, data formats, MCP integration, experiment results, skill integration. Fix Copilot review: remove unused sys import, close file handles. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Summary
Fixes #1044 — user configures Sonnet 4.5 in Claude Code but claude-flow forces Opus 4.5.
Three root causes found and fixed:
claude-opus-4-20250514→claude-opus-4-5-20251101(the old ID doesn't exist)ANTHROPIC_MODELwas unconditionally overwritten inexecuteClaudeCode(), ignoring any user-set value. Now respects existing env var.headless.tsruntime passedmodel: 'sonnet'as a config override, stomping each worker's own model preference. Removed so workers use their configured model.Changes
v3/.../headless-worker-executor.tsANTHROPIC_MODELenv varv3/.../headless.tsmodel: 'sonnet'overrideTest plan
ANTHROPIC_MODEL=claude-sonnet-4-20250514in env, run a headless worker — should use Sonnet, not Opusultralearnanddeepdiveworkers should correctly resolve to Opus 4.5 (new model ID)🤖 Generated with Claude Code