Skip to content

claude: enable Claude Code native gateway model discovery - #347

Merged
andy-xu-db merged 4 commits into
mainfrom
claude/native-model-discovery
Aug 20, 2026
Merged

claude: enable Claude Code native gateway model discovery#347
andy-xu-db merged 4 commits into
mainfrom
claude/native-model-discovery

Conversation

@andy-xu-db

@andy-xu-db andy-xu-db commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds opt-in support for Claude Code's native gateway model discovery. Set ENABLE_CLAUDE_CODE_GATEWAY_MODEL_DISCOVERY=1 before launching ucode to have Claude Code's /model picker list every gateway Messages-API endpoint, rather than only the ANTHROPIC_DEFAULT_* family aliases ucode injects today.

Why

Claude Code has native gateway model discovery: when enabled, it fetches GET {ANTHROPIC_BASE_URL}/v1/models and adds a picker row for each returned id (filtered to ids containing claude or anthropic). Keeping this behind an opt-in ucode environment flag prevents behavior changes for existing users while allowing custom Model Serving endpoints whose ids carry claude/anthropic (for example, main.default.my_anthropic_ms or system.ai.claude-opus-4-8) to appear and route natively as 3-part FQNs.

What changed

  • render_overlay sets CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 only when ENABLE_CLAUDE_CODE_GATEWAY_MODEL_DISCOVERY is enabled (1, true, or yes).
  • Discovery remains disabled under provider: a Model Provider Service routes every request to the external provider via header, so a discovered gateway endpoint id would reach a provider that cannot resolve it.
  • Relayed launches work because the loopback refresh proxy (gateway_proxy.py) forwards /v1/models to the gateway.

Testing

  • Verified disabled/default and false-value behavior.
  • Verified accepted opt-in values.
  • Verified the provider-service exclusion.
  • Full test_agent_claude.py suite passes (110 tests).
  • Ruff passes.

This pull request and its description were written by Isaac.

Set CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 in render_overlay so the
/model picker lists every gateway Messages-API endpoint, not just the
ANTHROPIC_DEFAULT_* family aliases. Skipped under a Model Provider Service:
its routing header would send a discovered gateway id to a provider that
can't resolve it.

Co-authored-by: Isaac
@andy-xu-db
andy-xu-db requested a review from lilly-luo August 17, 2026 21:35

@lilly-luo lilly-luo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can you pls gate this behind an environment feature flag (see ENABLE_MANAGED_AGENT_CONFIG) so that users won't break unless they explicitly use

@andy-xu-db

Copy link
Copy Markdown
Collaborator Author

Addressed the opt-in request in a5eb902. Gateway model discovery is now disabled by default and only enabled when ENABLE_CLAUDE_CODE_GATEWAY_MODEL_DISCOVERY is set to 1, true, or yes; the provider-service exclusion remains in place. Added coverage for disabled, enabled, and provider cases (110 Claude-agent tests passing).

Comment thread src/ucode/agents/claude.py Outdated
Comment thread src/ucode/agents/claude.py Outdated
@andy-xu-db
andy-xu-db enabled auto-merge (squash) August 20, 2026 19:24
@andy-xu-db

Copy link
Copy Markdown
Collaborator Author

/merge

@andy-xu-db
andy-xu-db merged commit 3f11590 into main Aug 20, 2026
2 checks passed
@andy-xu-db
andy-xu-db deleted the claude/native-model-discovery branch August 20, 2026 19:29
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.

2 participants