Skip to content

[codex] Reuse Apps policy evaluation across MCP tool exposure - #27813

Merged
mzeng-openai merged 5 commits into
mainfrom
dev/mzeng/reuse-app-tool-policy-evaluator
Jun 15, 2026
Merged

[codex] Reuse Apps policy evaluation across MCP tool exposure#27813
mzeng-openai merged 5 commits into
mainfrom
dev/mzeng/reuse-app-tool-policy-evaluator

Conversation

@mzeng-openai

@mzeng-openai mzeng-openai commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • move AppToolPolicyEvaluator and the Apps config/requirements policy logic from codex-core into codex-connectors
  • resolve one immutable policy snapshot per exposure build and reuse it across every Codex Apps MCP tool
  • keep core as a thin adapter from MCP metadata to connector-owned policy input while preserving the call-time defense-in-depth check

Why

build_mcp_tool_exposure evaluates every Codex Apps tool on each sampling request. The old path rebuilt effective Apps configuration for every tool, and the policy implementation lived in the already-large core crate even though it is connector-specific.

The connector-owned evaluator keeps the expensive config merge/decode out of the loop and gives core only the effective policy result it needs.

Performance

With the real 557-tool Apps corpus, build_mcp_tool_exposure measured 3.74 ms and 3.33 ms after the extraction (3.54 ms mean). The original path measured 807 ms mean, so the final result retains the 99.6% reduction.

Validation

  • cargo check -p codex-connectors -p codex-core
  • just test -p codex-connectors — 15 passed
  • just test -p codex-core --lib connectors — 35 passed
  • just test -p codex-core --lib mcp_tool_exposure — 5 passed
  • just test -p codex-core --lib mcp_tool_call — 72 passed
  • just bazel-lock-update
  • just bazel-lock-check
  • just fix -p codex-connectors
  • just fix -p codex-core
  • just fmt

@mzeng-openai
mzeng-openai force-pushed the dev/mzeng/reuse-app-tool-policy-evaluator branch from f34d2fc to eb2b726 Compare June 12, 2026 18:01
@mzeng-openai
mzeng-openai marked this pull request as ready for review June 12, 2026 19:00
@mzeng-openai
mzeng-openai requested a review from a team as a code owner June 12, 2026 19:00

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

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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc8e962fba

ℹ️ 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/connectors/Cargo.toml
Comment thread codex-rs/connectors/src/app_tool_policy.rs Outdated

@owenlin0 owenlin0 left a comment

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.

nice on moving this out of codex-core

Comment thread codex-rs/core/src/connectors_tests.rs Outdated
@mzeng-openai
mzeng-openai merged commit 1fbaac1 into main Jun 15, 2026
45 of 49 checks passed
@mzeng-openai
mzeng-openai deleted the dev/mzeng/reuse-app-tool-policy-evaluator branch June 15, 2026 22:24
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants