fix(cursor): subagent grep results in files and count modes are no longer empty#32220

open1
main
GitHub fork: fix/cursor-adapter
opened6d agobyMMarcoDotIO
View on GitHubTwo-way sync enabledPR last imported 6d ago

Problem

When a Cursor Task subagent runs a grep in files_with_matches or count mode, its row in the subagent's child thread shows no results, even when the grep found files.

The call path: a completed task tool call reaches emitSubagent, which replays the subagent's conversationSteps through toolCallsFromConversationSteps → nestedToolCallFromEnvelope → nestedGrepWorkspaceResults. The SDK builds those steps with protobuf toJson() (conversationSteps.map((e) => e.toJson?.() ?? e) in @cursor/sdk 1.2.0). In that format each workspace's GrepUnionResult is a oneof of content, files or count. nestedGrepWorkspaceResults read only content, so a files or count result became a content result with no matches. cursorToolSearchResults then had nothing to show.

Change

nestedGrepWorkspaceResults now maps the files and count cases to the same shapes the SDK uses for top-level grep calls: { type: "files", output: { files, count } } and { type: "count", output: { counts, total } }. cursorToolSearchResults already renders both shapes for top-level grep calls, so the child thread now lists the matching files, or each file with its "N matches" count. The content case is unchanged.

Scope and approval

This is a small fix for an obvious bug, so it has no issue. It changes one converter in the Cursor adapter, and the converter now matches the proto's own GrepUnionResult oneof. Contracts, settings and clients do not change. The child thread's grep row now shows the results it should have shown; the layout does not change.

Not in this PR, and covered elsewhere:

  • Top-level content-mode grep conversion inside the SDK: #25037.
  • Nested shell failures shown as raw JSON, and live subagent streaming: #29785 and #30539.

Verification

I extended projects subagent search results Cursor serialized with protobuf toJson in packages/provider-cursor/src/server/adapter.test.ts, the existing subagent test whose steps are shaped like toJson() output. It now includes one files_with_matches grep step and one count grep step.

Before the fix (upstream main), both new rows come back empty:

1- "results": [
2- { "fileName": "src/a.ts" },
3- { "fileName": "src/b.ts" },
4- ],
5+ "results": [],
6...
7- "results": [
8- { "fileName": "src/a.ts", "preview": "1 match" },
9- { "fileName": "src/b.ts", "preview": "3 matches" },
10- ],
11+ "results": [],
12
13 Tests 1 failed | 20 skipped (21)

After the fix:

1vp test run packages/provider-cursor/src/server/adapter.test.ts
2 Tests 21 passed (21)

Targeted vp lint and vp fmt --check on packages/provider-cursor/src/server passed, and effect-tsgo typecheck in packages/provider-cursor reported 0 errors.

Not checked: a live Cursor subagent run. The toJson() shape comes from the SDK's proto descriptors (GrepUnionResult|1 count|2 files|3 content, GrepFilesResult|1 files|2 total_files, GrepCountResult|1 counts|2 total_files|3 total_matches) and from the SDK code that serializes the steps. It was not captured from a real run.

Reviewed with sol-loop: 1 round with gpt-6.1-sol. Sol verdict: approved

Created with Claude Opus 5.5 in the Claude Code desktop app.

🤖 Generated with Claude Code

Checks

24 successful · 7 skipped
All checks passed
a4a1d55

Added 1 commit

  • fix(cursor): subagent grep results in files and count modes are no longer emptya4a1d55
Synced from GitHub

Approvability

Verdict: Approved at a4a1d55

Macroscope's review found this PR approvable — This restores file lists and match counts in Cursor subagent grep results using existing rendering support. The change is limited to result conversion, with no changes to search execution or product defaults.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Cursor adapter now maps nested grep files and count results to search output. Tests cover both variants through protobuf toJson() serialization.

Changes: Cursor grep result parsing

Layer / File(s)Summary
Map grep variants and verify output
packages/provider-cursor/src/server/adapter.ts, packages/provider-cursor/src/server/adapter.test.ts
The adapter maps valid file and count entries, using retained-entry totals when the provided totals are not numeric. Tests verify file results and per-file match-count previews in serialized output.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested labels: bugfix, size:M

Suggested reviewers: juliusmarminge

Merge Risk: External image Minimal · up to a4a1d

The new grep modes produce the expected file and count results in the covered cases. No actionable merge risk remains after normal checks.

Pre-merge checks: Passed 4

Check nameStatusExplanation
Title checkPassedThe title clearly identifies the Cursor subagent grep fix and both affected modes.
Description checkPassedThe description covers the problem, change, scope, and verification. It explains why the fix needs no prior issue and identifies the live check that was not performed.
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
External image Recent review info

External image Run configuration

External image Commits

Reviewing files that changed from the base of the PR and between b90e554e0a942605c4de2d4ff5d4654caf998e27 and a4a1d55c08a1539977587d5bf9cfce95e4fb53cc.

External image Files selected for processing: 2

  • packages/provider-cursor/src/server/adapter.test.ts
  • packages/provider-cursor/src/server/adapter.ts

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