Skip to content

[BUG] Rig agent ignores [llm].model and CODEGRAPH_MODEL, defaulting Anthropic to Sonnet #73

Description

@gudzenkov

Summary

The Rig agent path does not use the configured [llm].model or the CODEGRAPH_MODEL environment variable. With Anthropic selected, it defaults to claude-sonnet-4-20250514 unless CODEGRAPH_LLM_MODEL or CODEGRAPH_AGENT_MODEL is set.

This makes CLI/config output misleading and can unexpectedly route requests to a more constrained or more expensive model.

Related

  • No matching issue or PR found for CODEGRAPH_MODEL, CODEGRAPH_LLM_MODEL, Rig model selection, or Anthropic defaulting to Sonnet.

Clean Reproduction

Config file:

[llm]
provider = "anthropic"
model = "claude-haiku-4-5"
context_window = 200000
max_retries = 1

Environment:

CODEGRAPH_LLM_PROVIDER=anthropic
CODEGRAPH_MODEL=claude-haiku-4-5

Official MCP call with correct project id:

{
  "name": "agentic_context",
  "arguments": {
    "query": "Find where this feature is implemented. Return concrete files and symbols.",
    "focus": "search",
    "limit": 1
  }
}

Observed error shows the request went to Sonnet, not Haiku:

429 Too Many Requests ...
model: claude-sonnet-4-20250514
rate limit of 30,000 input tokens per minute

When rerun with:

CODEGRAPH_LLM_MODEL=claude-haiku-4-5
CODEGRAPH_AGENT_MODEL=claude-haiku-4-5

the same path used Haiku:

model: claude-haiku-4-5-20251001
rate limit of 50,000 input tokens per minute

Code Evidence

crates/codegraph-mcp-rig/src/adapter/llm_adapter.rs:

pub fn get_model_name() -> String {
    env::var("CODEGRAPH_LLM_MODEL")
        .or_else(|_| env::var("CODEGRAPH_AGENT_MODEL"))
        .unwrap_or_else(|_| default_model_for_provider())
}

fn default_model_for_provider() -> String {
    match RigProvider::from_env() {
        Ok(RigProvider::Anthropic) => "claude-sonnet-4-20250514".to_string(),
        // ...
    }
}

The Rig path does not read config.llm.model from ConfigManager and does not read CODEGRAPH_MODEL, even though ConfigManager supports CODEGRAPH_MODEL.

Expected

Model selection should be consistent across config and runtime paths:

  • [llm].model should affect the Rig MCP path.
  • CODEGRAPH_MODEL should either work consistently or be documented as not applicable.
  • If Rig requires CODEGRAPH_LLM_MODEL, the CLI/config docs should make that explicit.

Actual

The official MCP Rig path silently defaults Anthropic to Sonnet despite config/env selecting Haiku.

Impact

Users can unknowingly run a different model from the one configured, changing cost, quality, context limits, and provider rate-limit behavior.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions