Skip to content

Commit 9ce9308

Browse files
authored
fix(cursor): improve automatic and manual sdk tracing (#2698)
With this we should be in a great place for supporting the new https://cursor.com/blog/agent-sdk > πŸ€– **This text was AI-generated.** Fix matching for minified ESM/CommonJS builds while preserving automatic/manual tracing parity. Capture nested tools, reported status/errors, cancellation, truncation flags, and request IDs. Report cache-inclusive prompt usage without double-counting. Before: ```text Cursor Agent [task] |-- tool: shell [tool] `-- tool: task [tool] `-- Agent: task [task] (nested tool calls omitted) ``` After: ```text Cursor Agent [task] |-- shell [tool] `-- task [tool] `-- Cursor Subagent [task] `-- read [tool] ``` Example for SDK-reported task steps; available detail depends on the SDK.
1 parent 5286934 commit 9ce9308

21 files changed

Lines changed: 1463 additions & 1493 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"braintrust": patch
3+
---
4+
5+
fix(cursor): improve automatic and manual sdk tracing

β€Že2e/scenarios/cursor-sdk-instrumentation/__snapshots__/cursor-sdk-v1-auto-hook.span-tree.jsonβ€Ž

Lines changed: 5 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Že2e/scenarios/cursor-sdk-instrumentation/__snapshots__/cursor-sdk-v1-auto-hook.span-tree.txtβ€Ž

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,8 @@ span_tree:
1111
β”‚ }
1212
β”‚ └── Cursor Agent [task]
1313
β”‚ input: "Reply with exactly: CURSOR_PROMPT_OK. Do not modify files."
14-
β”‚ output: {
15-
β”‚ "durationMs": 0,
16-
β”‚ "id": "<span:1>",
17-
β”‚ "model": {
18-
β”‚ "id": "<span:2>"
19-
β”‚ },
20-
β”‚ "status": "error"
21-
β”‚ }
2214
β”‚ metadata: {
15+
β”‚ "cursor_sdk.agent_id": "agent-<uuid:2>",
2316
β”‚ "cursor_sdk.duration_ms": 0,
2417
β”‚ "cursor_sdk.local.cwd": "<repo>/e2e/scenarios/cursor-sdk-instrumentation/",
2518
β”‚ "cursor_sdk.model": "composer-2",
@@ -31,9 +24,7 @@ span_tree:
3124
β”‚ "model": "composer-2",
3225
β”‚ "provider": "cursor"
3326
β”‚ }
34-
β”‚ metrics: {
35-
β”‚ "duration": 0
36-
β”‚ }
27+
β”‚ error: "Cursor run failed"
3728
β”œβ”€β”€ cursor-sdk-stream-operation
3829
β”‚ metadata: {
3930
β”‚ "operation": "stream",
@@ -51,9 +42,7 @@ span_tree:
5142
β”‚ "model": "composer-2",
5243
β”‚ "provider": "cursor"
5344
β”‚ }
54-
β”‚ metrics: {
55-
β”‚ "duration": 0
56-
β”‚ }
45+
β”‚ error: "Cursor run failed"
5746
β”œβ”€β”€ cursor-sdk-wait-operation
5847
β”‚ metadata: {
5948
β”‚ "operation": "wait",
@@ -71,9 +60,7 @@ span_tree:
7160
β”‚ "model": "composer-2",
7261
β”‚ "provider": "cursor"
7362
β”‚ }
74-
β”‚ metrics: {
75-
β”‚ "duration": 0
76-
β”‚ }
63+
β”‚ error: "Cursor run failed"
7764
└── cursor-sdk-resume-conversation-operation
7865
metadata: {
7966
"operation": "resume-conversation",
@@ -90,6 +77,4 @@ span_tree:
9077
"model": "composer-2",
9178
"provider": "cursor"
9279
}
93-
metrics: {
94-
"duration": 0
95-
}
80+
error: "Cursor run failed"

β€Že2e/scenarios/cursor-sdk-instrumentation/__snapshots__/cursor-sdk-v1-latest-auto-hook.span-tree.jsonβ€Ž

Lines changed: 5 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Že2e/scenarios/cursor-sdk-instrumentation/__snapshots__/cursor-sdk-v1-latest-auto-hook.span-tree.txtβ€Ž

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,8 @@ span_tree:
1111
β”‚ }
1212
β”‚ └── Cursor Agent [task]
1313
β”‚ input: "Reply with exactly: CURSOR_PROMPT_OK. Do not modify files."
14-
β”‚ output: {
15-
β”‚ "durationMs": 0,
16-
β”‚ "id": "<span:1>",
17-
β”‚ "model": {
18-
β”‚ "id": "<span:2>"
19-
β”‚ },
20-
β”‚ "status": "error"
21-
β”‚ }
2214
β”‚ metadata: {
15+
β”‚ "cursor_sdk.agent_id": "agent-<uuid:2>",
2316
β”‚ "cursor_sdk.duration_ms": 0,
2417
β”‚ "cursor_sdk.local.cwd": "<repo>/e2e/scenarios/cursor-sdk-instrumentation/",
2518
β”‚ "cursor_sdk.model": "composer-2",
@@ -31,9 +24,7 @@ span_tree:
3124
β”‚ "model": "composer-2",
3225
β”‚ "provider": "cursor"
3326
β”‚ }
34-
β”‚ metrics: {
35-
β”‚ "duration": 0
36-
β”‚ }
27+
β”‚ error: "Cursor run failed"
3728
β”œβ”€β”€ cursor-sdk-stream-operation
3829
β”‚ metadata: {
3930
β”‚ "operation": "stream",
@@ -51,9 +42,7 @@ span_tree:
5142
β”‚ "model": "composer-2",
5243
β”‚ "provider": "cursor"
5344
β”‚ }
54-
β”‚ metrics: {
55-
β”‚ "duration": 0
56-
β”‚ }
45+
β”‚ error: "Cursor run failed"
5746
β”œβ”€β”€ cursor-sdk-wait-operation
5847
β”‚ metadata: {
5948
β”‚ "operation": "wait",
@@ -71,9 +60,7 @@ span_tree:
7160
β”‚ "model": "composer-2",
7261
β”‚ "provider": "cursor"
7362
β”‚ }
74-
β”‚ metrics: {
75-
β”‚ "duration": 0
76-
β”‚ }
63+
β”‚ error: "Cursor run failed"
7764
└── cursor-sdk-resume-conversation-operation
7865
metadata: {
7966
"operation": "resume-conversation",
@@ -90,6 +77,4 @@ span_tree:
9077
"model": "composer-2",
9178
"provider": "cursor"
9279
}
93-
metrics: {
94-
"duration": 0
95-
}
80+
error: "Cursor run failed"

β€Že2e/scenarios/cursor-sdk-instrumentation/__snapshots__/cursor-sdk-v1-latest-wrapped.span-tree.jsonβ€Ž

Lines changed: 4 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Že2e/scenarios/cursor-sdk-instrumentation/__snapshots__/cursor-sdk-v1-latest-wrapped.span-tree.txtβ€Ž

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ span_tree:
1111
β”‚ }
1212
β”‚ └── Cursor Agent [task]
1313
β”‚ input: "Reply with exactly: CURSOR_PROMPT_OK. Do not modify files."
14-
β”‚ output: {
15-
β”‚ "durationMs": 0,
16-
β”‚ "id": "<span:1>",
17-
β”‚ "model": {
18-
β”‚ "id": "<span:2>"
19-
β”‚ },
20-
β”‚ "status": "error"
21-
β”‚ }
2214
β”‚ metadata: {
2315
β”‚ "cursor_sdk.duration_ms": 0,
2416
β”‚ "cursor_sdk.local.cwd": "<repo>/e2e/scenarios/cursor-sdk-instrumentation/",
@@ -30,9 +22,7 @@ span_tree:
3022
β”‚ "model": "composer-2",
3123
β”‚ "provider": "cursor"
3224
β”‚ }
33-
β”‚ metrics: {
34-
β”‚ "duration": 0
35-
β”‚ }
25+
β”‚ error: "Cursor run failed"
3626
β”œβ”€β”€ cursor-sdk-stream-operation
3727
β”‚ metadata: {
3828
β”‚ "operation": "stream",
@@ -50,9 +40,7 @@ span_tree:
5040
β”‚ "model": "composer-2",
5141
β”‚ "provider": "cursor"
5242
β”‚ }
53-
β”‚ metrics: {
54-
β”‚ "duration": 0
55-
β”‚ }
43+
β”‚ error: "Cursor run failed"
5644
β”œβ”€β”€ cursor-sdk-wait-operation
5745
β”‚ metadata: {
5846
β”‚ "operation": "wait",
@@ -70,9 +58,7 @@ span_tree:
7058
β”‚ "model": "composer-2",
7159
β”‚ "provider": "cursor"
7260
β”‚ }
73-
β”‚ metrics: {
74-
β”‚ "duration": 0
75-
β”‚ }
61+
β”‚ error: "Cursor run failed"
7662
└── cursor-sdk-resume-conversation-operation
7763
metadata: {
7864
"operation": "resume-conversation",
@@ -89,6 +75,4 @@ span_tree:
8975
"model": "composer-2",
9076
"provider": "cursor"
9177
}
92-
metrics: {
93-
"duration": 0
94-
}
78+
error: "Cursor run failed"

0 commit comments

Comments
Β (0)