Skip to content

Support custom Claude model endpoints via --model-prefix#128

Open
hackerrdave wants to merge 1 commit into
databricks:mainfrom
hackerrdave:feat/claude-custom-model-prefix
Open

Support custom Claude model endpoints via --model-prefix#128
hackerrdave wants to merge 1 commit into
databricks:mainfrom
hackerrdave:feat/claude-custom-model-prefix

Conversation

@hackerrdave
Copy link
Copy Markdown

Problem

ucode discovered Claude models only by the hardcoded databricks-claude-<family>- name and pinned the newest one per family. Workspaces that serve Claude through custom serving endpoints — e.g. Bedrock-backed models named acme-bedrock-claude-opus-4-8 on the AI Gateway anthropic route — matched nothing, so Claude couldn't be configured.

What changed

  • --model-prefix flag. Configure custom Claude endpoints by their shared prefix before the family token. Fits the CLI's existing --agents/--workspaces "configure without prompting" idiom and is self-documented in ucode configure --help. Setting a Bedrock prefix scopes discovery to those endpoints and excludes hosted databricks-claude-* models, since they no longer match the prefix. Default stays databricks-claude- (existing behavior unchanged).
  • Persisted + precedence. The resolved prefix is saved as a claude_model_prefix state key, so the flag only needs to be passed on the first configure for a workspace. Precedence: --model-prefix flag > persisted state > default.
  • Allowlist + multi-version. discover_claude_models now returns (defaults, allowed, reason). The newest match per family is the default; every matching endpoint stays selectable. Stored as sibling state keys (claude_allowed_models, claude_model_prefix) so the flat claude_models shape its existing consumers rely on is untouched.
  • Client-side enforcement. Writes the matching set (endpoint ids + family aliases) to Claude Code's availableModels setting so the /model picker is restricted to the discovered models. The Databricks gateway remains the hard backstop.
  • Visibility. ucode status surfaces the resolved prefix, per-family defaults, extra versions, and selectable-model count.
  • Docs. New README subsection for --model-prefix.

Usage

ucode configure --agents claude --model-prefix acme-bedrock-claude-

Testing

uv run pytest (621 passed, 27 skipped) and uv run ruff check . clean. Tests cover prefix scoping / hosted exclusion, prefix-resolution precedence, the --model-prefix flag threading into discovery and persisting, availableModels contents, and the status rendering.

🤖 Generated with Claude Code

ucode discovered Claude models only by the hardcoded
`databricks-claude-<family>-` name and pinned the newest per family.
Workspaces that serve Claude through custom endpoints (e.g. Bedrock-backed
`acme-bedrock-claude-opus-4-8`) found no models.

Add a `--model-prefix` flag to `ucode configure` for the shared prefix before
the family token. It fits the CLI's existing `--agents`/`--workspaces` idiom
and is self-documented in `--help`. Setting a Bedrock prefix scopes discovery
to those endpoints and excludes hosted `databricks-claude-*` models, which no
longer match the prefix. Default stays `databricks-claude-` (unchanged).

- discover_claude_models now returns (defaults, allowed, reason): newest match
  per family is the default; every matching endpoint stays in the allowlist so
  additional versions remain selectable.
- Persist the allowlist (claude_allowed_models) and resolved prefix
  (claude_model_prefix) as sibling state keys to keep the flat claude_models
  shape its existing consumers rely on. Precedence: flag > persisted > default,
  so the flag is only needed on the first configure for a workspace.
- Write the allowlist (endpoint ids + family aliases) to Claude Code's
  `availableModels` setting so the /model picker is restricted to the discovered
  models; the gateway remains the hard backstop.
- ucode status surfaces the resolved prefix, per-family defaults, extra
  versions, and selectable-model count.
- Document --model-prefix in the README.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.

1 participant