Skip to content

[codex] Add model tool mode selector#25031

Merged
aibrahim-oai merged 11 commits into
mainfrom
codex/model-info-tool-mode
May 29, 2026
Merged

[codex] Add model tool mode selector#25031
aibrahim-oai merged 11 commits into
mainfrom
codex/model-info-tool-mode

Conversation

@aibrahim-oai
Copy link
Copy Markdown
Collaborator

@aibrahim-oai aibrahim-oai commented May 29, 2026

Why

Some models need to select their code-execution behavior through model catalog metadata. Models without that metadata must continue to follow the existing CodeMode and CodeModeOnly feature flags, including when a newer server sends an enum value this client does not recognize.

What changed

  • add optional ModelInfo.tool_mode metadata with direct, code_mode, and code_mode_only
  • treat omitted and unknown wire values as None
  • resolve None from the existing feature flags
  • carry the resolved ToolMode directly on TurnContext, outside Config
  • use the resolved value for turn creation, model switches, review turns, tool planning, and code execution

Coverage

  • add protocol coverage for omitted, known, and unknown enum values
  • add focused coverage for flag fallback and explicit metadata overriding feature flags
  • add core integration coverage that fetches remote model metadata through /v1/models and verifies the outbound /responses tools for explicit direct and code_mode_only selectors

Stack

@aibrahim-oai
Copy link
Copy Markdown
Collaborator Author

aibrahim-oai commented May 29, 2026

This change is part of the following stack:

Change managed by git-spice.

@aibrahim-oai aibrahim-oai marked this pull request as ready for review May 29, 2026 07:04
@aibrahim-oai aibrahim-oai requested a review from a team as a code owner May 29, 2026 07:04
@aibrahim-oai aibrahim-oai marked this pull request as draft May 29, 2026 07:12
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7c264fbbd2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/model_runtime.rs Outdated
Comment on lines +14 to +16
tool_mode: model_info
.tool_mode
.unwrap_or_else(|| tool_mode_from_features(features)),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge Keep metadata-driven code mode behind a context cap

When the /models payload sets tool_mode to code_mode or code_mode_only, this overrides the local CodeMode feature flags, so model metadata can now expose the codex freeform tool even in sessions where code mode was not locally enabled. In code_mode_only, build_exec_tool_description expands every visible nested tool, including MCP/extension/dynamic tool descriptions, into one model-visible tool description with no hard cap; that new individual context item can exceed the >1k-token manual-review threshold and has no 10K-token bound. Please keep CodeMode as a local gate or cap/truncate the generated description before exposing metadata-driven code mode.

Useful? React with 👍 / 👎.

Comment thread codex-rs/core/src/model_runtime.rs Outdated
Comment on lines +14 to +16
tool_mode: model_info
.tool_mode
.unwrap_or_else(|| tool_mode_from_features(features)),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve tool_mode in lockfile replays

When config-lock replay is used with the default save_fields_resolved_from_model_catalog = true, the lockfile drops model_catalog_json after saving resolved catalog-derived fields, but this new tool_mode selector is not saved anywhere. In that replay/resume context, a later remote catalog change for the same model can make this line choose a different mode and override the lockfile’s materialized feature flags, so the same locked session can gain or lose the code-mode tool surface while validation still passes; persist the resolved selector or encode it into the locked feature state.

Useful? React with 👍 / 👎.

Comment thread codex-rs/core/src/tools/spec_plan_tests.rs
@aibrahim-oai aibrahim-oai marked this pull request as ready for review May 29, 2026 07:29
@aibrahim-oai aibrahim-oai marked this pull request as draft May 29, 2026 07:33
@aibrahim-oai aibrahim-oai changed the title [codex] Add model tool mode metadata selector [codex] Add model tool mode selector May 29, 2026
@aibrahim-oai aibrahim-oai marked this pull request as ready for review May 29, 2026 07:48
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I maintain my comment on the other side that we probably need something more generic to control the config from the model

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2261e0814d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

#[serde(rename_all = "snake_case")]
pub enum ToolMode {
Direct,
CodeMode,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Cover the code_mode catalog selector

The new code_mode selector is a distinct wire value, but the added integration coverage only drives remote metadata through direct and code_mode_only; existing Code Mode tests still reach this path via local feature flags. A regression that deserializes or resolves tool_mode: "code_mode" incorrectly for remote models would pass the current suite, so please add a focused integration test that feeds code_mode metadata and asserts the resulting outbound Code Mode tools/worker behavior.

Useful? React with 👍 / 👎.

@aibrahim-oai aibrahim-oai merged commit 5577a9e into main May 29, 2026
31 checks passed
@aibrahim-oai aibrahim-oai deleted the codex/model-info-tool-mode branch May 29, 2026 16:05
@github-actions github-actions Bot locked and limited conversation to collaborators May 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants