Skip to content

fix: respect user's model selection instead of forcing overrides#1050

Open
srobinson wants to merge 1 commit intoruvnet:mainfrom
srobinson:fix/respect-user-model-selection
Open

fix: respect user's model selection instead of forcing overrides#1050
srobinson wants to merge 1 commit intoruvnet:mainfrom
srobinson:fix/respect-user-model-selection

Conversation

@srobinson
Copy link

Summary

Fixes #1044 — user configures Sonnet 4.5 in Claude Code but claude-flow forces Opus 4.5.

Three root causes found and fixed:

  • Wrong Opus model ID: claude-opus-4-20250514claude-opus-4-5-20251101 (the old ID doesn't exist)
  • Env var stomping: ANTHROPIC_MODEL was unconditionally overwritten in executeClaudeCode(), ignoring any user-set value. Now respects existing env var.
  • Hardcoded sonnet override: headless.ts runtime passed model: 'sonnet' as a config override, stomping each worker's own model preference. Removed so workers use their configured model.

Changes

File Change
v3/.../headless-worker-executor.ts Fix Opus model ID, respect existing ANTHROPIC_MODEL env var
v3/.../headless.ts Remove hardcoded model: 'sonnet' override

Test plan

  • Set ANTHROPIC_MODEL=claude-sonnet-4-20250514 in env, run a headless worker — should use Sonnet, not Opus
  • Without env var set, workers should use their configured default model
  • ultralearn and deepdive workers should correctly resolve to Opus 4.5 (new model ID)

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings January 30, 2026 14:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-20250514 to claude-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.

Comment on lines +1122 to +1124
if (!env.ANTHROPIC_MODEL) {
env.ANTHROPIC_MODEL = MODEL_IDS[options.model];
}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for respecting the user's ANTHROPIC_MODEL environment variable is not covered by tests. Consider adding a test case that verifies:

  1. When ANTHROPIC_MODEL is already set in process.env, it should not be overridden
  2. 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.

Copilot uses AI. Check for mistakes.
srobinson added a commit to srobinson/fmm that referenced this pull request Jan 30, 2026
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>
srobinson added a commit to srobinson/fmm that referenced this pull request Jan 30, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model selected in claude code is not used

2 participants