Skip to content

feat(codex): support amazon_bedrock Model Provider Services that expose OpenAI-compatible models - #455

Open
bjanssen11 wants to merge 6 commits into
databricks:mainfrom
bjanssen11:feat/codex-bedrock-mps-2
Open

feat(codex): support amazon_bedrock Model Provider Services that expose OpenAI-compatible models#455
bjanssen11 wants to merge 6 commits into
databricks:mainfrom
bjanssen11:feat/codex-bedrock-mps-2

Conversation

@bjanssen11

@bjanssen11 bjanssen11 commented Sep 2, 2026

Copy link
Copy Markdown

Related to #454

Summary

Fix: codex + Bedrock MPS validation

  • Add "amazon_bedrock" to codex's allowed provider types in _TOOL_PROVIDER_TYPES (was ("openai",) only)
  • Gate the "exposes no Claude models" check in resolve_provider_service on tool == "claude" so a Bedrock MPS with non-Claude targets isn't rejected when codex picks it
  • Apply the same tool == "claude" guard in service_usable_for_tool so Bedrock services without Claude targets appear in the listing for codex

Codex uses the OpenAI-compatible endpoint. Bedrock exposes this same interface for non-Claude models. There's no reason to require Claude targets when codex is the active tool.

Fix: Bedrock model picker shows OpenAI models

When ucode codex --provider <bedrock-mps> launched, Codex's built-in model picker queried OpenAI and showed gpt-5-codex/gpt-5 instead of the Bedrock targets declared on the MPS.

  • At launch time, fetch the MPS targets and offer a picker (or auto-pin when there's only one)
  • Honor explicit --model for codex in the provider path (was previously a no-op)
  • Make codex.write_tool_config use the model parameter when a provider is active (was silently ignored)

New: ucode providers commands

  • ucode providers list [--tool TOOL] — lists all MPS services on the workspace with name, provider type, and declared targets. --tool claude|codex filters to services the given tool can route through.
  • ucode providers show <catalog.schema.service> — shows full detail for one MPS: provider type, relay flag, allow_all_targets, and the complete targets list.

Test plan

  • test_codex_bedrock_openai_compat_ok — codex + Bedrock MPS exposing only non-Claude targets now resolves successfully
  • test_codex_bedrock_with_claude_targets_ok — codex + Bedrock MPS with Claude targets also works
  • test_codex_anthropic_rejected — codex still can't route to an Anthropic MPS
  • test_codex_filters_to_openai_and_bedrock — updated from test_codex_filters_to_openai to verify Bedrock services appear in codex's listing
uv run pytest tests/test_databricks.py tests/test_agent_codex.py tests/test_agents_init.py tests/test_lint.py  # 409 passed
uv run ruff check .   # no issues

🤖 Generated with Claude Code

https://claude.ai/code/session_017G9kjrbhqvWucH26GwykSn

bjanssen11 and others added 6 commits September 2, 2026 10:54
Codex speaks the OpenAI-compatible API, which Bedrock also exposes.
`_TOOL_PROVIDER_TYPES` previously restricted codex to `openai` only, so
`ucode codex --provider <bedrock-mps>` always failed with "which codex
can't route to (supported: openai)."

Three changes in databricks.py:
- Add `amazon_bedrock` to codex's allowed provider types in
  `_TOOL_PROVIDER_TYPES`.
- Gate the "exposes no Claude models" check in `resolve_provider_service`
  on `tool == "claude"` so a Bedrock MPS with OpenAI-compatible (non-Claude)
  targets isn't rejected when codex selects it.
- Apply the same `tool == "claude"` guard in `service_usable_for_tool` so
  Bedrock services without Claude targets appear in the list when codex is
  the active tool.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017G9kjrbhqvWucH26GwykSn
Adds two new subcommands under `ucode providers` to inspect Model
Provider Services on the workspace:

- `ucode providers list [--tool TOOL]` — lists all MPS services with
  name, provider type, and declared targets. `--tool claude|codex`
  filters to services the given tool can actually route through.
- `ucode providers show <catalog.schema.service>` — shows full detail
  for one service: provider type, relay flag, allow_all_targets, and
  the complete targets list.

Motivation: after `ucode codex --provider eng_dev.ai_gateway.amazonbedrock`
launched without showing expected Bedrock models, there was no CLI to
inspect what targets an MPS exposes.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017G9kjrbhqvWucH26GwykSn
When `ucode codex --provider <bedrock-mps>` is used, Codex's built-in
model picker queries OpenAI for its model list — showing gpt-5-codex and
gpt-5 instead of the Bedrock targets declared on the MPS.

Fix this by:
- Fetching the MPS targets at launch time and offering a picker (or
  auto-pinning when there's only one target)
- Honoring an explicit `--model` flag for codex in the provider path,
  which was previously a no-op
- Making `codex.write_tool_config` actually use the `model` parameter
  when a provider is active (it was silently ignored before)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017G9kjrbhqvWucH26GwykSn
Wire `ucode pi --provider <bedrock-mps>` end-to-end:

- `build_pi_base_urls`: add "bedrock" key pointing at `{workspace}/ai-gateway`
  (NOT `/ai-gateway/amazonbedrock` — that path maps to the Bedrock control
  plane; the standard path routes to the runtime via the MPS header)
- `pi.render_overlay`: add `databricks-bedrock` provider block when
  `bedrock_targets` is supplied; defaults the session to the first target
- `pi.write_tool_config`: accept `provider` and `bedrock_targets` kwargs
- `agents.__init__.configure_tool`: pass `bedrock_targets` to Pi; allow
  Pi to launch without a model when a Bedrock provider + targets cover it
- `cli.py`: fetch MPS targets for Pi in the provider launch path; handle
  `allow_all_targets` with a text prompt; thread `bedrock_targets` through
  to `configure_tool`

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017G9kjrbhqvWucH26GwykSn
Without it, --provider fell into ctx.args and was forwarded to Pi itself
rather than being parsed by ucode, so the Bedrock target-fetching branch
never ran.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017G9kjrbhqvWucH26GwykSn
Without this entry, ucode pi --provider rejects any Bedrock MPS with
"pi can't route to (supported: none)" before ever fetching targets.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017G9kjrbhqvWucH26GwykSn
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