Skip to content

feat: best-effort compact large tool schemas#23904

Merged
celia-oai merged 6 commits into
mainfrom
dev/cc/compact-schema
May 22, 2026
Merged

feat: best-effort compact large tool schemas#23904
celia-oai merged 6 commits into
mainfrom
dev/cc/compact-schema

Conversation

@celia-oai
Copy link
Copy Markdown
Collaborator

@celia-oai celia-oai commented May 21, 2026

Why

The dev/cc/ref-def branch preserves richer JSON Schema detail for connector tools, including $defs and nested shapes. That improves fidelity, but it pushes the largest connector schemas well past the intended tool-schema budget. This PR adds a best-effort compaction pass for unusually large tool input schemas so the p99 and max tails stay small while ordinary schemas are left alone.

What Changed

  • Added best-effort large-schema compaction in codex-rs/tools/src/json_schema.rs after schema sanitization and definition pruning.
  • Compaction runs as a waterfall only while the compact JSON budget proxy is exceeded:
    1. Strip schema description metadata.
    2. Drop root $defs / definitions.
    3. Collapse deep nested complex schema objects to {}.
  • Kept top-level argument names and immediate schema shape where possible.

Corpus Results

Scope: 2,025 schemas under golden_schemas, all parsed successfully. Token count is o200k_base over compact JSON from parse_tool_input_schema.

Percentile Before origin/main 4dbca61e20 After branch dev/cc/ref-def f9bf071758 After this PR
p0 9 9 9
p10 59 63 63
p25 81 86 86
p50 114 127 125
p75 174 205 202
p90 295 335 322
p95 391 526 422
p99 794 1,303 689
max 2,836 3,337 887

After this PR, 0 / 2,025 schemas are over 1k tokens.

Compaction Savings

These are cumulative waterfall stages over the same corpus. Later passes only run for schemas that are still over the compact JSON budget proxy.

Stage Total tokens Step savings Schemas changed by step
No compaction 391,862 - -
Strip schema description metadata 350,961 40,901 66
Drop root $defs / definitions 340,683 10,278 13
Collapse deep complex schemas to {} 335,875 4,808 6

@celia-oai celia-oai force-pushed the dev/cc/compact-schema branch 4 times, most recently from ac122ea to d16a35f Compare May 21, 2026 18:34
@celia-oai celia-oai changed the title changes Best-effort compact large tool schemas May 21, 2026
@celia-oai celia-oai changed the title Best-effort compact large tool schemas feat: best-effort compact large tool schemas May 21, 2026
@celia-oai celia-oai marked this pull request as ready for review May 21, 2026 18:54
@celia-oai celia-oai force-pushed the dev/cc/compact-schema branch from d16a35f to 2fd9682 Compare May 21, 2026 18:54
@celia-oai celia-oai requested a review from pakrym-oai May 21, 2026 18:55
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: 2fd9682429

ℹ️ 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/tools/src/json_schema.rs
Comment thread codex-rs/tools/src/json_schema.rs Outdated
Comment thread codex-rs/tools/src/json_schema.rs Outdated
Comment thread codex-rs/tools/src/json_schema.rs Outdated
Comment thread codex-rs/tools/src/json_schema.rs Outdated
Comment thread codex-rs/tools/src/json_schema.rs Outdated
Comment thread codex-rs/tools/src/json_schema.rs
Comment thread codex-rs/tools/src/json_schema_tests.rs Outdated
Comment thread codex-rs/tools/src/json_schema_tests.rs
@celia-oai celia-oai force-pushed the dev/cc/compact-schema branch from d747075 to 93779ac Compare May 21, 2026 19:30
@celia-oai celia-oai force-pushed the dev/cc/compact-schema branch 3 times, most recently from db23b72 to 9860d3c Compare May 21, 2026 21:15
@celia-oai
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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".

@celia-oai celia-oai force-pushed the dev/cc/compact-schema branch 3 times, most recently from b74b130 to 0ef6923 Compare May 21, 2026 22:16
@celia-oai
Copy link
Copy Markdown
Collaborator Author

@codex review

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: 0ef6923873

ℹ️ 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/tools/src/json_schema.rs
Comment thread codex-rs/tools/src/json_schema.rs
Comment thread codex-rs/tools/src/json_schema.rs Outdated
@celia-oai celia-oai force-pushed the dev/cc/compact-schema branch 2 times, most recently from 0ef6923 to 416e53e Compare May 21, 2026 23:31
@celia-oai celia-oai force-pushed the dev/cc/compact-schema branch from 416e53e to c14c9d1 Compare May 21, 2026 23:45
Base automatically changed from dev/cc/ref-def to main May 22, 2026 00:32
@celia-oai celia-oai force-pushed the dev/cc/compact-schema branch from 73ec600 to 368d872 Compare May 22, 2026 01:03
@celia-oai
Copy link
Copy Markdown
Collaborator Author

@codex review

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: 368d8729db

ℹ️ 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/tools/src/json_schema.rs
Comment thread codex-rs/tools/src/json_schema.rs
Comment thread codex-rs/tools/src/json_schema.rs
Comment thread codex-rs/tools/src/json_schema.rs
@celia-oai celia-oai force-pushed the dev/cc/compact-schema branch from 368d872 to f553d8f Compare May 22, 2026 01:13
@celia-oai celia-oai enabled auto-merge (squash) May 22, 2026 01:13
@celia-oai celia-oai merged commit 464ab40 into main May 22, 2026
31 checks passed
@celia-oai celia-oai deleted the dev/cc/compact-schema branch May 22, 2026 01:26
@github-actions github-actions Bot locked and limited conversation to collaborators May 22, 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