feat(codex): support amazon_bedrock Model Provider Services that expose OpenAI-compatible models - #455
Open
bjanssen11 wants to merge 6 commits into
Open
feat(codex): support amazon_bedrock Model Provider Services that expose OpenAI-compatible models#455bjanssen11 wants to merge 6 commits into
bjanssen11 wants to merge 6 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #454
Summary
Fix: codex + Bedrock MPS validation
"amazon_bedrock"to codex's allowed provider types in_TOOL_PROVIDER_TYPES(was("openai",)only)resolve_provider_serviceontool == "claude"so a Bedrock MPS with non-Claude targets isn't rejected when codex picks ittool == "claude"guard inservice_usable_for_toolso Bedrock services without Claude targets appear in the listing for codexCodex 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 showedgpt-5-codex/gpt-5instead of the Bedrock targets declared on the MPS.--modelfor codex in the provider path (was previously a no-op)codex.write_tool_configuse themodelparameter when a provider is active (was silently ignored)New:
ucode providerscommandsucode providers list [--tool TOOL]— lists all MPS services on the workspace with name, provider type, and declared targets.--tool claude|codexfilters 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 successfullytest_codex_bedrock_with_claude_targets_ok— codex + Bedrock MPS with Claude targets also workstest_codex_anthropic_rejected— codex still can't route to an Anthropic MPStest_codex_filters_to_openai_and_bedrock— updated fromtest_codex_filters_to_openaito verify Bedrock services appear in codex's listing🤖 Generated with Claude Code
https://claude.ai/code/session_017G9kjrbhqvWucH26GwykSn