Skip to content

fix(config): add default LLM model fallbacks for cloud providers#1239

Open
D4rk-Pho3nix wants to merge 1 commit into
CodeGraphContext:mainfrom
D4rk-Pho3nix:feat/default-model-name-fallback
Open

fix(config): add default LLM model fallbacks for cloud providers#1239
D4rk-Pho3nix wants to merge 1 commit into
CodeGraphContext:mainfrom
D4rk-Pho3nix:feat/default-model-name-fallback

Conversation

@D4rk-Pho3nix

Copy link
Copy Markdown

closes #1103

Summary (program: gssoc)

Fixes a crash when OPENAI_MODEL or ANTHROPIC_MODEL is missing from config. The change adds provider defaults directly to DEFAULT_CONFIG, so graph queries have a model to use without any extra setup.

What's New

  • Default model fallbacks: Added OPENAI_MODEL (gpt-4o) and ANTHROPIC_MODEL (claude-3-5-sonnet-20241022) to DEFAULT_CONFIG in config_manager.py, so graph queries always have a model to fall back on.
    To test: Remove OPENAI_MODEL or ANTHROPIC_MODEL from ~/.codegraphcontext/.env and run a graph query. It should complete without error.
  • resolve_model_name helper: Added resolve_model_name(provider, configured_value), a function that returns the configured model when set, or the provider default when the value is empty, None, or absent.
    To test: from codegraphcontext.cli.config_manager import resolve_model_name; resolve_model_name("openai", "") returns "gpt-4o"
  • Tests: tests/unit/cli/test_model_defaults.py has 12 unit tests covering default values, fallback behavior, whitespace stripping, case-insensitive provider names, and unknown providers.

Feature Implementation

Testing Edge Cases 👇

1103.1.mp4
1103-2 1103

Files Changed

  • src/codegraphcontext/cli/config_manager.py - added OPENAI_MODEL and ANTHROPIC_MODEL to DEFAULT_CONFIG and CONFIG_DESCRIPTIONS, added resolve_model_name() helper
  • tests/unit/cli/test_model_defaults.py - new file, 12 unit tests

Edge Cases Covered

  • Config value is None -> falls back to provider default ✅
  • Config value is "" -> falls back to provider default ✅
  • Config value has surrounding whitespace (" gpt-4o ") -> stripped before returning ✅
  • Provider name is mixed-case ("OpenAI", "ANTHROPIC") -> resolved case-insensitively ✅
  • Unknown provider ("mistral") -> returns "", no crash ✅
  • Existing non-empty config value -> returned unchanged ✅

Type of Change

  • Bug fix (non-breaking)

@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

@D4rk-Pho3nix is attempting to deploy a commit to the shashankss1205's projects Team on Vercel.

A member of the Team first needs to authorize it.

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

Labels

None yet

Projects

Status: Backlog tasks

Development

Successfully merging this pull request may close these issues.

Default Model Name Fallbacks for Cloud Providers

1 participant