[WRONG BRANCH] fix(cursor): preserve malformed buffered tool args - #276
[WRONG BRANCH] fix(cursor): preserve malformed buffered tool args#276luvs01 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe change preserves incomplete streamed tool-call arguments when completion provides no structured argument map. A regression test verifies deferred start emission, the preserved argument delta, and the tool-call end event. ChangesCursor tool argument handling
Estimated code review effort: 1 (Trivial) | ~5 minutes Mergeability Score: ⚪ Minimal · up to This localized change preserves malformed buffered tool arguments instead of converting them to empty arguments, with focused tests and validation passing; no actionable merge-blocking risk remains. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Its title has been prefixed with |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0233e50917
ℹ️ 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".
| const name = mcpWireNameFromArgs(args); | ||
| if (isCompleteJson(buffered)) return normalizeJsonText(buffered, name, state); | ||
| return ""; | ||
| return buffered; |
There was a problem hiding this comment.
Reject whitespace-only buffered arguments
When argsTextDelta contains only whitespace and completion has no argument map, returning the truthy buffer does not fail closed: toolCallArgumentsUsable trims it and accepts it as an empty no-arg call, while closeCurrentToolCall preserves the original whitespace instead of substituting {}. The response is therefore marked completed with arguments: " ", which is not valid JSON and can make the echoed call fail on the next turn. Reject whitespace-only non-empty buffers as malformed rather than forwarding them.
AGENTS.md reference: src/AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
Motivation
argsTextDeltaand, when a completion arrived with no structured map, treated an incomplete JSON buffer as empty arguments, which the bridge serialized as{}and caused malformed/truncated arguments to be silently accepted downstream instead of failing-closed.Description
resolveCompletedArgsto preserve the bufferedargsTextDeltawhen it is non-empty but not complete JSON, so malformed/truncated argument blobs are forwarded instead of being conflated with a genuinely no-arg call.preserves incomplete streamed args when completion has no argument mapintests/cursor-protobuf-events.test.tsto verify the adapter emits the buffered truncated text at completion.src/adapters/cursor/protobuf-events.ts,tests/cursor-protobuf-events.test.ts.Testing
bun test tests/cursor-protobuf-events.test.ts, which passed (34 passed, 0 failed).bun run typecheck(tsc --noEmit), which completed cleanly.bun run privacy:scan, which passed.git diff --check(no whitespace or diff issues found).Codex Task
Summary by CodeRabbit
Bug Fixes
Tests