Skip to content

[Bug]: Cursor resource_exhausted with large Codex namespace tool catalog #190

Closed

Description

@alexanderxcmo

Summary

Cursor-routed models fail deterministically with resource_exhausted when Codex advertises a large namespace-based tool catalog. The same Cursor OAuth account and model work when the namespace tools are removed, and both halves of the catalog work independently.

This appears related to, but more specifically reproducible than, #72. PR #73 improved error classification/retry behavior, but the upstream rejection can still be triggered by the aggregate client tool catalog.

Environment

  • OpenCodex: 2.7.28
  • Codex CLI: 0.144.6 (also observed from Codex Desktop)
  • OS: macOS
  • Provider: Cursor OAuth
  • Models reproduced: cursor/grok-4.5 and cursor/auto
  • Cursor quota was not exhausted, and native Cursor usage continued to work

Error

stream disconnected before completion: Cursor rate limit exceeded: Cursor Connect error resource_exhausted: Error

Provider debug shows that Cursor Connect succeeds, returns its first frame, requests multiple blobs, and then terminates with resource_exhausted:

[ocx:cursor:connected]
[ocx:cursor:first-frame]
[ocx:cursor:frame] {"case":"kvServerMessage","kv":"getBlobArgs"}
...
[ocx:cursor:connect-end-stream] {"code":"resource_exhausted"}

Reproduction

  1. Configure the Cursor OAuth provider.
  2. Use a Codex installation with multiple apps/plugins, producing a namespace-based tool catalog.
  3. Select cursor/grok-4.5 or cursor/auto.
  4. Send a trivial prompt in a fresh session.

A fresh ephemeral CLI session also reproduces it:

codex exec \
  --ignore-user-config \
  -c openai_base_url='"http://127.0.0.1:10100/v1"' \
  --skip-git-repo-check \
  --ephemeral \
  -m cursor/grok-4.5 \
  -c model_reasoning_effort='"medium"' \
  "Reply only OK"

Request measurements

The failing minimal Codex request was zstd-compressed on the wire and measured after local decompression:

  • Total request: 505,203 bytes
  • Tool catalog: 443,259 bytes
  • Top-level tools: 24
  • Namespace entries: 13
  • Inner namespace tools: 340

The largest namespaces included GitHub (89 tools), Linear (59), Google Drive (46), Slack (32), Neon Postgres (29), Figma (27), Vercel (24), and Sites (20).

Isolation results

All tests used the same Cursor OAuth account, model, prompt, and OpenCodex transport:

Tool catalog Result
Full catalog: 340 inner namespace tools Fails consistently with resource_exhausted
Namespace tools removed; native top-level tools retained Succeeds
First group: 230 inner namespace tools Succeeds
Second group: 110 inner namespace tools Succeeds
Minimal direct /v1/responses request without the Codex tool catalog Succeeds

Because both groups succeed independently, this does not look like one individually malformed tool schema. The failure depends on the aggregate catalog.

Suspected area

This may be related to commit 80b510f, which started mirroring Responses client tools into AgentRunRequest.mcp_tools so they become callable by Cursor models. Existing tests appear to validate small tool sets, but not a large namespace catalog.

The exact Cursor boundary is not yet known: it may be serialized byte size, total tool count, blob count, or another internal resource budget. OpenCodex currently classifies the result as a rate limit, although account quota is not the trigger in this reproduction.

Expected behavior

OpenCodex should avoid sending a Cursor tool catalog that the upstream cannot accept. Possible approaches:

  • enforce a Cursor-specific serialized tool/count budget;
  • defer large namespace catalogs and expose them through tool_search only when needed;
  • preserve Codex-native tools while limiting optional MCP/app tools;
  • surface an actionable tool-catalog-limit error instead of a quota-oriented message.

I can provide additional redacted provider-debug output or test a proposed patch if useful.

Activity

  1. added a commit that references this issue on Jul 20, 2026
    cecde52
  2. Ingwannu commented on Jul 21, 2026

    @Ingwannu
    Owner

    Confirmed: the issue is real. Current dev registered the full client catalog in Cursor's McpTools protobuf with no aggregate byte/count bound, and also classified resource_exhausted as an account-style rate limit.

    I did not merge the closed #192 implementation because its review identified three correctness gaps: estimated rather than serialized byte size, reserved tools escaping the hard count cap, and no reliable promotion path for tools returned by tool_search.

    A replacement is now on dev in d048463:

    • measures the actual serialized McpTools protobuf, including names, descriptions, provider identifiers, and schemas;
    • enforces one hard ceiling of 330 definitions and 120,000 serialized bytes;
    • prioritizes explicit choices, tools returned by tool_search, and native Codex tools;
    • skips a single oversized definition while continuing to admit later small definitions;
    • uses the same bounded catalog for advertisement and tool-call recognition;
    • classifies residual catalog exhaustion as HTTP 400 tool_catalog_too_large, not a quota/rate-limit failure.

    Regression coverage includes oversized schemas, combined count overflow, tool-search promotion, recovery-note honesty, wire error classification, and request logging. The full repository suite passed (3,296 tests), plus the post-change focused suite. This run did not perform a credential-dependent live Cursor smoke, so please reopen with a redacted provider-debug trace if the upstream still rejects a bounded catalog.

    Closing as fixed on dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions