Skip to content

Pin Codex to the MPS's primary model on provider launch - #621

Open
masonc08 wants to merge 2 commits into
mainfrom
mason.cao/codex-mps-default-model
Open

masonc08 wants to merge 2 commits into
mainfrom
mason.cao/codex-mps-default-model

Conversation

@masonc08

Copy link
Copy Markdown
Collaborator

Summary

ug codex --provider <MPS> writes the MPS's models into Codex's picker (model_catalog_json) but left the active model to Codex's own bundled default (e.g. gpt-5.6-sol). An MPS allowlist doesn't route that slug, so the first request returned 403 PERMISSION_DENIED: Model '...' is not in the allowed models list.

When MPS model discovery succeeds, pin the active model to the MPS's primary (first) catalog target — unless the user passed -m/--model or a managed default already applies. Orthogonal to #611: only the discovery-success branch changes; the 404 fallback path stays untouched.

Changes

  • agents/codex.py: pin model from the fetched catalog in launch(); add _tool_args_select_model() so an explicit -m/--model still wins.
  • codex_config.py: extract catalog_slugs(catalog), shared by the file reader and the launch path.
  • Tests: pins first catalog model; respects user -m/--model; keeps a managed default; existing catalog test asserts the pin.

Testing

  • uv run --frozen pytest tests/test_agent_codex.py tests/test_codex_config.py tests/test_databricks.py tests/test_lint.py — 365 passed
  • uv run ruff format --check src/ tests/ and uv run ruff check src/ tests/ — clean

This pull request and its description were written by Isaac.

`ug codex --provider <MPS>` wrote the MPS's models into Codex's picker
(model_catalog_json) but left the active model to Codex's bundled default
(e.g. gpt-5.6-sol), which an MPS allowlist doesn't route -- so the first
request 403'd. When discovery succeeds, pin `model` to the MPS's primary
(first) target unless the user passed -m/--model or a managed default applies.

Co-authored-by: Isaac <no-reply@databricks.com>
Comment thread src/ucode/codex_config.py Outdated
Comment on lines +89 to +91
def _catalog_slugs(path: Path) -> list[str]:
"""Extract deduplicated model slugs from a Codex custom catalog JSON file."""
return catalog_slugs(read_json_safe(path))

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.

private func call a public func?

custom_catalog_models now calls the public catalog_slugs() on the JSON it
reads, so no private helper delegates to a public one.

Co-authored-by: Isaac <no-reply@databricks.com>
Comment thread src/ucode/agents/codex.py
# which an MPS's allowlist doesn't route, so the first request 403s. Pin
# the MPS's primary (first) target unless the user chose a model or a
# managed default already applies.
if not profile_doc.get("model") and not _tool_args_select_model(tool_args):

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.

where is this custom catalog coming from that has the models?

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.

2 participants