Skip to content

fix(cursor): budget buffered textual tool calls to prevent pre-finalization memory growth - #552

Closed
luvs01 wants to merge 1 commit into
devfrom
codex/propose-fix-for-text-toolcall-vulnerability
Closed

luvs01 wants to merge 1 commit into
devfrom
codex/propose-fix-for-text-toolcall-vulnerability

Conversation

@luvs01

@luvs01 luvs01 commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Close a memory-accounting hole where complete textual [TOOL_CALL]... markers were retained in bufferedTextToolCalls without charging the translator budget, allowing an upstream Cursor provider to accumulate many large argument strings before finalizeTurnEvents enforced limits.

Description

  • Immediately budget complete textual fallbacks when parsed by mapCursorProtobufServerMessage by opening a synthetic call id, reserving transient tool_args bytes, and committing the reservation before pushing into bufferedTextToolCalls (see src/adapters/cursor/protobuf-events.ts).
  • Ensure buffered fallback charges are released whenever a real client-tool frame wins or when buffered calls are dropped by adding discardBufferedTextToolCalls and closing the synthetic call leases in recordRealToolCall, the synthetic exec path, and finalizeTurnEvents.
  • Update the buffered structure to track a callId per retained entry so reservations map to the normal translator accounting, and adjust promotion to use the retained callId during recordToolCall/commitToolCall paths.
  • Add a regression test that asserts oversized fallback arguments are rejected immediately and that charges are released when a real tool frame supersedes the fallback, and update structure/providers/cursor.md to document the budget behavior.

Testing

  • Ran the focused Cursor suite with bun test tests/providers/cursor/cursor-protobuf-events.test.ts, which passed 63/63 tests after the change.
  • Ran bun run typecheck, bun run structure:check, and bun run privacy:scan, all of which completed successfully for the modified code.
  • The full repository bun run test was exercised but encountered existing, unrelated environment/concurrency failures in other suites; the focused Cursor coverage and privacy/type checks that verify this change passed.

Codex Task


Devin Review

@coderabbitai

coderabbitai Bot commented Sep 20, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: luvs01/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 27cfb50e-2a23-4723-9a5d-107cf46d0f67


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

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 20, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-20T06:20:26.500263Z 755d50b PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

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

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@luvs01

luvs01 commented Sep 22, 2026

Copy link
Copy Markdown
Owner Author

Consolidated into lidge-jun#5533 as a single related-function aggregate.

Source head: 755d50b139f7ecda576e0ce5617ac8b29a419418. Replacement head: 799ebc5d5d6a8c75eeb99f358db5c64906117584.

Source and carried commit 799ebc5 have identical stable Git patch IDs; original author and cherry-pick provenance are retained. Combined-head focused tests: 141 passed / 648 assertions, plus typecheck, structure and file-size checks. POSIX branches, full suite and hosted cross-platform CI remain unverified. Maintainer-owned lidge-jun#5507 is independent and was not changed or placed into a dependent chain.

Closing this duplicate standalone review entry at the author's request after verifying migration. This is not a merge or release claim; remaining integration checks and reviews are tracked on the draft replacement. Original branches are retained.

@luvs01 luvs01 closed this Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant