Skip to content

fix(catalog): bound eager tool warning diagnostics - #8810

Merged
lidge-jun merged 3 commits into
lidge-jun:devfrom
luvs01:fix/eager-catalog-diagnostic-budget
Nov 17, 2026
Merged

lidge-jun merged 3 commits into
lidge-jun:devfrom
luvs01:fix/eager-catalog-diagnostic-budget

Conversation

@luvs01

@luvs01 luvs01 commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The optional eager Codex MCP catalog warning could multiply a long namespace by every child tool name before checking any limit. An admitted compact request reached this diagnostic before model validation, so a small request could consume disproportionate process memory and hashing work without calling an upstream provider.

  • Share a per-request diagnostic budget of 4,096 inspected items and 1,048,576 UTF-16 code units.
  • Reserve generated-name cost before concatenation or Set insertion, including duplicates; reserve Code Mode description cost before parsing.
  • Bound current-turn replay scans/copies first and pass only the catalog projection to the existing provenance helper. Compact diagnostics do not inspect input history.
  • Skip the optional warning on exhaustion without retaining a partial count or marking the request as already warned. Keep the actual request and tool catalog unchanged.
  • Preserve normal deduplication, reserved functions namespace handling, deferred tools, Code Mode, current-turn provenance, and session/anonymous warning behavior.

Verification

Recorded local validation:

  • Independent prepatch inspection and a bounded pure-helper probe confirmed that a 20,422-byte input caused 4,195,730 canonical-name characters to be passed to Set insertion. No OOM test was needed.
  • All 12 new regressions failed against the original implementation.
  • bun test tests/responses/codex-eager-tool-catalog.test.ts: 53 passed / 149 assertions. This includes the real loopback HTTP route and an injected local upstream: all 4,096 tools are forwarded while only the warning is skipped.
  • Fresh independent review of the immutable implementation tree 76b27b6bf600cb46c118218c7e8db805aba2c9ea found no blocking issues. The reviewer reran the 53 focused tests and passed a further 1,221 pure in-memory assertions, including 600 generated parity cases and exact item/character/provenance boundaries.
  • The Spanish catalog guide includes the same diagnostic-budget exception as English. A separate review verified this three-line documentation-only delta. Spanish parity check: 30 passed / 3,226 assertions.

Posted-head CI 43812249151 passed, including the Typecheck step and test changed job. Catalog checks also passed. This is exact-head hosted evidence; the local results above are retained prior validation and were not rerun for this status change.

A source comparison against dev c36793a9336b70cfe5bc3b7f6e6f751e730fb6fc found no duplicate implementation or incompatible contract change requiring a rebase. Maintainer security review and installed/live application validation remain separate; review readiness does not claim merge or release acceptance.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

The security checkbox records implementation review; explicit maintainer security review remains required before merge.

Summary by CodeRabbit

  • Behavior
    • Catalog diagnostics now use a fixed work budget. If the catalog or surrounding request exceeds it, the warning is skipped and the request continues unchanged.
    • Exceeding the budget does not partially count tools or record a warning as already issued.
  • Documentation
    • Updated configuration and catalog guidance to describe the work limits and their effect on diagnostics.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The eager MCP catalog diagnostic now has request-wide limits of 4,096 entries and 1 MiB of diagnostic characters. When a limit is exceeded, it skips the warning and leaves request processing unchanged. Credential excerpt masking tests now measure masking time and whole-input search counts.

Changes: Eager catalog diagnostic budget

Layer / File(s) Summary
Bound catalog collection work
src/server/responses/codex-tool-catalog.ts
The diagnostic charges catalog entries and matching names against shared item and character limits. Code Mode descriptions and rendered names also consume budget.
Apply limits across request counting and verify outcomes
src/server/responses/codex-tool-catalog.ts, tests/responses/codex-eager-tool-catalog.test.ts, structure/catalog.md, docs-site/src/content/docs/reference/configuration/catalog.md, docs-site/src/content/docs/es/reference/configuration/catalog.md
The count function applies the shared limits to request inputs and returns 0 when collection exceeds a limit. Tests cover budget exhaustion, forwarding, and namespace-prefix matching. The English and Spanish documentation describe the limit and unchanged request processing.

Credential excerpt masking tests

Layer / File(s) Summary
Measure and verify excerpt masking
tests/responses/sse-untyped-credential-mask.test.ts
The tests time excerpt masking separately from the full terminal rewrite. They check that credential excerpts are masked, long suffixes remain unchanged, and masking does not repeatedly search the full input.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • lidge-jun/opencodex#8133: Introduces the eager Codex MCP catalog diagnostic that this change bounds with shared entry and character limits.

Suggested reviewers: atinseau

Merge Risk: Minimal · up to f50f7

This change bounds an optional diagnostic warning and leaves request forwarding unchanged when the limit is exceeded. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(catalog): bound eager tool warning diagnostics" matches the main change. The PR adds a shared per-request budget of 4,096 items and 1,048,576 UTF-16 code units to the optional eager Cod…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(catalog): bound eager tool warning diagnostics" matches the main change. The PR adds a shared per-request budget of 4,096 items and 1,048,576 UTF-16 code units to the optional eager Codex MCP catalog warning diagnostic. The title is concise, specific, and follows a conventional commit style. It does not cover every detail, such as the Spanish docs update or the test changes, which is expected.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 595de1e and f50f78a.

Files selected for processing: 6

  • docs-site/src/content/docs/es/reference/configuration/catalog.md
  • docs-site/src/content/docs/reference/configuration/catalog.md
  • src/server/responses/codex-tool-catalog.ts
  • structure/catalog.md
  • tests/responses/codex-eager-tool-catalog.test.ts
  • tests/responses/sse-untyped-credential-mask.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@github-actions github-actions Bot added the bug Something isn't working label Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev under MAINTAINERS.md (not an approving review), 2026-11-17 triage round.

@lidge-jun
lidge-jun merged commit d4ac0db into lidge-jun:dev Nov 17, 2026
44 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants