Skip to content

Fix stale Claude model discovery setting - #445

Open
lilly-luo wants to merge 5 commits into
mainfrom
lilly-luo_data/stack/fix-claude-model-discovery-state
Open

Fix stale Claude model discovery setting#445
lilly-luo wants to merge 5 commits into
mainfrom
lilly-luo_data/stack/fix-claude-model-discovery-state

Conversation

@lilly-luo

@lilly-luo lilly-luo commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

problem: if i ran --enable-model-discovery or --enable-smart-routing at any point, then CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY env var gets set to 1.

However, it does not get pruned later if i run ucode claude without --enable-model-discovery. as such, once you enable model discovery, it's basically enabled forever.

this PR
1/ prunes CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY if --enable-model-discovery or --enable-smart-routing is not set
2/ avoids setting the env var in settings.json if the flags are passed

test:

  • confirm ucode claude --enable-model-discovery still works
  • confirm ucode claude --enable-model-discovery still works but when i close, the settings.json does not leave behind CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
  • confirm ucode claude --enable-smart-routing still works
  • confirm ucode claude --enable-smart-routing still works but when i close, the settings.json does not leave behind CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1

@lilly-luo
lilly-luo force-pushed the lilly-luo_data/stack/fix-claude-model-discovery-state branch from 30400ea to ce72b71 Compare September 2, 2026 02:23
@lilly-luo
lilly-luo force-pushed the lilly-luo_data/stack/fix-claude-model-discovery-state branch from ce72b71 to 3f2c822 Compare September 2, 2026 02:27
@lilly-luo
lilly-luo marked this pull request as ready for review September 2, 2026 02:30
@lilly-luo
lilly-luo requested a review from andy-xu-db September 2, 2026 13:08
Comment on lines -400 to -407
# Native /model discovery: picker lists every gateway Messages-API endpoint,
# not just the family aliases. Skipped under a provider (its routing header
# would send a discovered gateway id to a provider that can't resolve it).
discovery_enabled = (
os.environ.get(GATEWAY_MODEL_DISCOVERY_ENV_VAR) == "1" or smart_routing_v2.enabled()
)
if discovery_enabled and not provider:
env["CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY"] = "1"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

key change

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.

1 participant