Skip to content

[AIGTWY-4573] Apply managed models and headers to Claude's config - #597

Open
david-siqi-liu wants to merge 6 commits into
david/AIGTWY-4573from
david/AIGTWY-4573-model-picker
Open

david-siqi-liu wants to merge 6 commits into
david/AIGTWY-4573from
david/AIGTWY-4573-model-picker

Conversation

@david-siqi-liu

@david-siqi-liu david-siqi-liu commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

Resolve the managed config's Claude inputs into Claude Code's own config shape: the model allow-list or discovery location into the /model picker, and the custom http_headers into Claude's outbound requests. Scoped to Claude; Codex and Gemini per-agent model/header handling is a follow-up so this stays a small, single-agent change.

Changes:

  • managed_resolve: add managed_static_models, managed_model_service_location, and managed_custom_headers; extend managed_state_overrides to layer claude_static_models, the model_service_location, and claude_custom_headers into state for Claude.
  • claude: a static list becomes availableModels + enforceAvailableModels + a modelPicker (exactly the named ids); a discovery location turns on gateway discovery instead. Ownership markers prune only ug-owned picker keys on a static-to-discovery transition, and clear only when the OS-managed file was written. Managed http_headers append to ANTHROPIC_CUSTOM_HEADERS, ug's fixed headers winning on conflict; values that would break the newline-delimited format are dropped.
  • databricks: shared extra_custom_headers helper drops reserved (ug-owned) and delimiter-unsafe headers so ug's headers always win.
  • README: document the Claude picker and the ucode-settings.json managed file.

This pull request and its description were written by Isaac.

@david-siqi-liu
david-siqi-liu added this pull request to stack #598 September 13, 2026 18:20
@david-siqi-liu
david-siqi-liu force-pushed the david/AIGTWY-4573-model-picker branch from c4e3c93 to 480b654 Compare September 13, 2026 23:29
@david-siqi-liu
david-siqi-liu force-pushed the david/AIGTWY-4573-model-picker branch from 480b654 to 055db11 Compare September 14, 2026 17:51
@david-siqi-liu david-siqi-liu changed the title [AIGTWY-4573] Apply managed models and headers to each agent's config [AIGTWY-4573] Apply managed models and headers to Claude's config Sep 14, 2026
@david-siqi-liu
david-siqi-liu force-pushed the david/AIGTWY-4573-model-picker branch from 055db11 to 6edfdf9 Compare September 14, 2026 18:46
@david-siqi-liu
david-siqi-liu force-pushed the david/AIGTWY-4573-model-picker branch from 6edfdf9 to 23d8bd8 Compare September 14, 2026 19:15
@david-siqi-liu
david-siqi-liu force-pushed the david/AIGTWY-4573-model-picker branch from 23d8bd8 to 73056a3 Compare September 14, 2026 19:55
@david-siqi-liu
david-siqi-liu force-pushed the david/AIGTWY-4573-model-picker branch from 73056a3 to f563c47 Compare September 14, 2026 20:59
@david-siqi-liu
david-siqi-liu force-pushed the david/AIGTWY-4573-model-picker branch from f563c47 to 07773dd Compare September 14, 2026 21:16
@david-siqi-liu
david-siqi-liu force-pushed the david/AIGTWY-4573-model-picker branch from 07773dd to 0a11b4e Compare September 14, 2026 22:44
@david-siqi-liu
david-siqi-liu force-pushed the david/AIGTWY-4573-model-picker branch from 0a11b4e to 6e7a30d Compare September 14, 2026 23:27
@david-siqi-liu
david-siqi-liu force-pushed the david/AIGTWY-4573-model-picker branch from 6e7a30d to 98447bc Compare September 14, 2026 23:36
@david-siqi-liu
david-siqi-liu force-pushed the david/AIGTWY-4573-model-picker branch from 98447bc to 6b8bb9d Compare September 15, 2026 01:05
@david-siqi-liu
david-siqi-liu force-pushed the david/AIGTWY-4573-model-picker branch from 6b8bb9d to 329ebdd Compare September 15, 2026 01:20
Comment on lines +483 to +486
elif model_service_location and not provider and not relayed:
env["CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY"] = "1"
keys.append(["env", "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY"])

@lilly-luo lilly-luo Sep 15, 2026

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.

we should sync w @andy-xu-db and make sure that model_service_location gets set + propagated correctly in discovery header

owned_paths: list[list[str]],
relayed: bool,
) -> None:
) -> bool:

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.

nit it's a bit unclear what the bool means from the method name _reconcile_managed_settings. maybe make it a dataclass

@dataclass 
class ManagedSettingsReconciliationResult
    written: bool 

Resolve the managed config's Claude inputs into Claude Code's own config shape: the model allow-list
or discovery location into the `/model` picker, and the custom http_headers into Claude's outbound
requests. Scoped to Claude; Codex and Gemini per-agent model/header handling is deferred to a
follow-up so this stays a small, single-agent change.

- managed_resolve: add managed_static_models, managed_model_service_location, and
  managed_custom_headers; extend managed_state_overrides to layer claude_static_models, the
  model_service_location, and claude_custom_headers into state for Claude.
- claude: a static list becomes availableModels + enforceAvailableModels + a modelPicker (exactly
  the named ids); a discovery location turns on gateway discovery instead. Ownership markers prune
  only ug-owned picker keys on a static-to-discovery transition, and clear only when the OS-managed
  file was written. Managed http_headers append to ANTHROPIC_CUSTOM_HEADERS, with ug's fixed headers
  winning on conflict; values that would break the newline-delimited header format are dropped.
- databricks: shared extra_custom_headers helper drops reserved (ug-owned) and delimiter-unsafe
  headers so ug's headers always win.
- README: document the Claude picker and the ucode-settings.json managed file.

Co-authored-by: Isaac <no-reply@databricks.com>
@david-siqi-liu
david-siqi-liu force-pushed the david/AIGTWY-4573-model-picker branch from 75bc51a to 93de22e Compare September 15, 2026 20:12
tt-le and others added 4 commits September 15, 2026 20:12
When a managed CodingAgentConfig enables tracing for an agent, ucode writes the
OpenTelemetry env plus a refreshing `otelHeadersHelper` into Claude Code's managed
settings so spans export to the AI Gateway OTLP ingest endpoint
(`/ai-gateway/otel/v1/traces`).

- managed_config: normalize per-agent `AgentConfig.tracing_config.enabled` →
  `otel_tracing_enabled` (tri-state), with the deprecated workspace-level
  `CodingAgentConfig.tracing` kept only as a back-compat fallback.
- managed_resolve: `managed_otel_tracing_enabled(managed, tool)` — per-agent wins,
  deprecated global falls back; `OTEL_TRACING_TOOLS` (claude only today) gates a
  per-agent `{tool}_otel_tracing` state override, the extension point for other agents.
- claude: render_overlay writes the trace env (`CLAUDE_CODE_ENABLE_TELEMETRY`, the
  `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA` span gate, `OTEL_TRACES_EXPORTER=otlp`,
  `http/protobuf`, the full `/v1/traces` endpoint via `build_otel_traces_endpoint`,
  debounce) plus `otelHeadersHelper`. No static `OTEL_..._HEADERS`. Disable prunes them.
- cli/databricks: `ucode otel-headers` prints the OTLP header map as JSON, minting the
  same Databricks token as `auth-token`.

Co-authored-by: Isaac <no-reply@databricks.com>
Set CLAUDE_CODE_PROPAGATE_TRACEPARENT=1 alongside the OTLP trace-export
env so Claude emits a W3C traceparent on its gateway-bound requests
(custom ANTHROPIC_BASE_URL). This lets the AI Gateway link its
server-side span to Claude's client-side span. Recorded as a managed
key so a later disable prunes it.

Co-authored-by: Isaac <no-reply@databricks.com>
Extend the OTel tracing rail (stacked on the Claude PR) to Codex: add `codex` to
`OTEL_TRACING_TOOLS`, so a managed per-agent `tracing_config.enabled` for the codex agent
sets `codex_otel_tracing` in state. At launch, `codex.py` mints a fresh Databricks bearer and
injects the `[otel.trace_exporter.otlp-http]` block (endpoint + http/protobuf + Authorization)
as `-c` config overrides — the endpoint is the AI Gateway ingest path, minted per launch and
never persisted.

Codex has no OTLP headers-helper (unlike Claude's otelHeadersHelper), so the bearer is pinned
statically per launch and goes stale after ~1h; a refreshing local proxy is the intended
follow-up. Inference and OTel auth are independent in Codex (model_providers.auth vs
otel.headers) and both use the same workspace bearer.

Co-authored-by: Isaac <no-reply@databricks.com>
…tion

A managed `models.unity_catalog_location` now scopes the agent's gateway model
discovery to that schema, like `--parent`, by emitting the Databricks-Model-
Service-Parent-Schema header. Previously the location only set
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY for Claude (unscoped, so the
location's models never appeared) and did nothing for Codex.

- claude.py: render_overlay emits the parent-schema header from
  model_service_location (covers `ug configure` and launch), not just the
  discovery-enable env.
- cli.py: launch derives parent_schema from the managed location so Codex
  (which has no model_service_location) gets the same scope header.

Co-authored-by: Isaac <no-reply@databricks.com>
@david-siqi-liu
david-siqi-liu force-pushed the david/AIGTWY-4573-model-picker branch from f7451c6 to 9427467 Compare September 15, 2026 20:50
…ches

The MPS model pin (first catalog target via `-c model=`) also fired for a
parent-schema (unity_catalog_location) launch, so the `-c model=` override
outranked the user's `/model` selection and reverted it every time. Scope the
pin to the MPS/provider case; a unity_catalog_location launch lets the user
pick any discovered model.

Co-authored-by: Isaac <no-reply@databricks.com>
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.

3 participants