[Enhancement]: Claude Code lists the deployment's models when Relay supplies the credential
Affected area
Framework integrations
Problem or opportunity
When Relay supplies the upstream credential ([upstream.anthropic_oidc] or [upstream.anthropic_api_key_helper]), nemo-relay run --agent claude does not let Claude Code ask the gateway for its model list. Claude Code then never fetches the models that the deployment allows, so its /model picker cannot list them.
The Relay gateway already serves the Anthropic GET /v1/models route. Claude Code calls it only when CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 is set, and Relay does not set it today.
Measured on main (12a36d49) with Claude Code 2.1.322, nemo-relay run --agent claude -- -p "say ok", and a local stub upstream that logs each request ([upstream.anthropic_api_key_helper]):
- Today: Claude Code sends only
POST /v1/messages. It sends noGET /v1/models. - With
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1set: Claude Code sendsGET /v1/models?limit=1000through Relay to the upstream, thenPOST /v1/messages.
Proposed enhancement
In crates/cli/src/agents/claude/launch.rs (prepare), when relay_supplies_credential is true, set CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 as a process default. Use the same rule as CLAUDE_CODE_GATEWAY_HINT_HEADERS: set it only when the caller's environment does not already have it. A caller can turn discovery off with CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=0.
When the caller brings their own Anthropic credential, Relay changes nothing.
Runtime contract and binding impact
No change to the gateway, routes, or bindings. The Claude Code child process gets one more environment variable, only when Relay supplies the credential. Docs: docs/nemo-relay-cli/claude-code.mdx.
Alternatives considered
- Document the variable and let each user set it. Every user of OIDC or a key helper then needs one more manual step.
- Always set it. A user with their own Anthropic key would then see a list that Relay did not choose.
Acceptance criteria
- Unit tests in
crates/cli/tests/coverage/agents/launcher_tests.rs: the variable is set when Relay supplies the credential, is not set when the caller brings a credential, and is not overwritten when the caller already set it (0,1, or empty). - Through Relay with a stub upstream, Claude Code sends
GET /v1/modelsbeforePOST /v1/messages, and sends none when the caller sets the variable to0. - The docs page names the variable and how to turn it off.