Skip to content

Commit 41f3681

Browse files
galkleinmanclaude
andauthored
fix(ai-sdk): agent name in span names when available (#838)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9e28821 commit 41f3681

File tree

7 files changed

+756
-36
lines changed

7 files changed

+756
-36
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
{
2+
"log": {
3+
"_recordingName": "Test AI SDK Agent Integration with Recording/should preserve original AI SDK span name when no agent metadata is provided",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.6"
8+
},
9+
"entries": [
10+
{
11+
"_id": "9b04bce29b1900d3b2a6a9d7046cadaf",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 669,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"name": "content-type",
20+
"value": "application/json"
21+
}
22+
],
23+
"headersSize": 165,
24+
"httpVersion": "HTTP/1.1",
25+
"method": "POST",
26+
"postData": {
27+
"mimeType": "application/json",
28+
"params": [],
29+
"text": "{\"model\":\"gpt-4o-mini\",\"input\":[{\"role\":\"user\",\"content\":[{\"type\":\"input_text\",\"text\":\"Calculate 10 + 5 using the calculator tool\"}]}],\"tools\":[{\"type\":\"function\",\"name\":\"calculate\",\"description\":\"Perform basic mathematical calculations\",\"parameters\":{\"type\":\"object\",\"properties\":{\"operation\":{\"type\":\"string\",\"enum\":[\"add\",\"subtract\",\"multiply\",\"divide\"],\"description\":\"The mathematical operation to perform\"},\"a\":{\"type\":\"number\",\"description\":\"First number\"},\"b\":{\"type\":\"number\",\"description\":\"Second number\"}},\"required\":[\"operation\",\"a\",\"b\"],\"additionalProperties\":false,\"$schema\":\"http://json-schema.org/draft-07/schema#\"},\"strict\":false}],\"tool_choice\":\"auto\"}"
30+
},
31+
"queryString": [],
32+
"url": "https://api.openai.com/v1/responses"
33+
},
34+
"response": {
35+
"bodySize": 2246,
36+
"content": {
37+
"mimeType": "application/json",
38+
"size": 2246,
39+
"text": "{\n \"id\": \"resp_0344a918ad130e3500692c6b9b6c6c81948d2136ba18a4b7da\",\n \"object\": \"response\",\n \"created_at\": 1764518811,\n \"status\": \"completed\",\n \"background\": false,\n \"billing\": {\n \"payer\": \"developer\"\n },\n \"error\": null,\n \"incomplete_details\": null,\n \"instructions\": null,\n \"max_output_tokens\": null,\n \"max_tool_calls\": null,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n \"output\": [\n {\n \"id\": \"fc_0344a918ad130e3500692c6b9c484c81949e4d78cd2cd5e3f1\",\n \"type\": \"function_call\",\n \"status\": \"completed\",\n \"arguments\": \"{\\\"operation\\\":\\\"add\\\",\\\"a\\\":10,\\\"b\\\":5}\",\n \"call_id\": \"call_bUdyZcVeNChXGxWMEhK4d1yC\",\n \"name\": \"calculate\"\n }\n ],\n \"parallel_tool_calls\": true,\n \"previous_response_id\": null,\n \"prompt_cache_key\": null,\n \"prompt_cache_retention\": null,\n \"reasoning\": {\n \"effort\": null,\n \"summary\": null\n },\n \"safety_identifier\": null,\n \"service_tier\": \"default\",\n \"store\": true,\n \"temperature\": 1.0,\n \"text\": {\n \"format\": {\n \"type\": \"text\"\n },\n \"verbosity\": \"medium\"\n },\n \"tool_choice\": \"auto\",\n \"tools\": [\n {\n \"type\": \"function\",\n \"description\": \"Perform basic mathematical calculations\",\n \"name\": \"calculate\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"operation\": {\n \"type\": \"string\",\n \"enum\": [\n \"add\",\n \"subtract\",\n \"multiply\",\n \"divide\"\n ],\n \"description\": \"The mathematical operation to perform\"\n },\n \"a\": {\n \"type\": \"number\",\n \"description\": \"First number\"\n },\n \"b\": {\n \"type\": \"number\",\n \"description\": \"Second number\"\n }\n },\n \"required\": [\n \"operation\",\n \"a\",\n \"b\"\n ],\n \"additionalProperties\": false\n },\n \"strict\": false\n }\n ],\n \"top_logprobs\": 0,\n \"top_p\": 1.0,\n \"truncation\": \"disabled\",\n \"usage\": {\n \"input_tokens\": 79,\n \"input_tokens_details\": {\n \"cached_tokens\": 0\n },\n \"output_tokens\": 22,\n \"output_tokens_details\": {\n \"reasoning_tokens\": 0\n },\n \"total_tokens\": 101\n },\n \"user\": null,\n \"metadata\": {}\n}"
40+
},
41+
"cookies": [
42+
{
43+
"domain": ".api.openai.com",
44+
"httpOnly": true,
45+
"name": "_cfuvid",
46+
"path": "/",
47+
"sameSite": "None",
48+
"secure": true,
49+
"value": "qhF6jlfO3kBMCCEAUYYudNtdTel7T9a5wnIXPIIsHQ0-1764518813656-0.0.1.1-604800000"
50+
}
51+
],
52+
"headers": [
53+
{
54+
"name": "alt-svc",
55+
"value": "h3=\":443\"; ma=86400"
56+
},
57+
{
58+
"name": "cf-cache-status",
59+
"value": "DYNAMIC"
60+
},
61+
{
62+
"name": "cf-ray",
63+
"value": "9a6b982abaa5935b-TLV"
64+
},
65+
{
66+
"name": "connection",
67+
"value": "keep-alive"
68+
},
69+
{
70+
"name": "content-encoding",
71+
"value": "br"
72+
},
73+
{
74+
"name": "content-type",
75+
"value": "application/json"
76+
},
77+
{
78+
"name": "date",
79+
"value": "Sun, 30 Nov 2025 16:06:53 GMT"
80+
},
81+
{
82+
"name": "openai-organization",
83+
"value": "traceloop"
84+
},
85+
{
86+
"name": "openai-processing-ms",
87+
"value": "2161"
88+
},
89+
{
90+
"name": "openai-project",
91+
"value": "proj_tzz1TbPPOXaf6j9tEkVUBIAa"
92+
},
93+
{
94+
"name": "openai-version",
95+
"value": "2020-10-01"
96+
},
97+
{
98+
"name": "server",
99+
"value": "cloudflare"
100+
},
101+
{
102+
"name": "set-cookie",
103+
"value": "_cfuvid=qhF6jlfO3kBMCCEAUYYudNtdTel7T9a5wnIXPIIsHQ0-1764518813656-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None"
104+
},
105+
{
106+
"name": "strict-transport-security",
107+
"value": "max-age=31536000; includeSubDomains; preload"
108+
},
109+
{
110+
"name": "transfer-encoding",
111+
"value": "chunked"
112+
},
113+
{
114+
"name": "x-content-type-options",
115+
"value": "nosniff"
116+
},
117+
{
118+
"name": "x-envoy-upstream-service-time",
119+
"value": "2163"
120+
},
121+
{
122+
"name": "x-ratelimit-limit-requests",
123+
"value": "30000"
124+
},
125+
{
126+
"name": "x-ratelimit-limit-tokens",
127+
"value": "150000000"
128+
},
129+
{
130+
"name": "x-ratelimit-remaining-requests",
131+
"value": "29999"
132+
},
133+
{
134+
"name": "x-ratelimit-remaining-tokens",
135+
"value": "149999705"
136+
},
137+
{
138+
"name": "x-ratelimit-reset-requests",
139+
"value": "2ms"
140+
},
141+
{
142+
"name": "x-ratelimit-reset-tokens",
143+
"value": "0s"
144+
},
145+
{
146+
"name": "x-request-id",
147+
"value": "req_96d279fdabd64f3abe3f1805c8183b32"
148+
}
149+
],
150+
"headersSize": 958,
151+
"httpVersion": "HTTP/1.1",
152+
"redirectURL": "",
153+
"status": 200,
154+
"statusText": "OK"
155+
},
156+
"startedDateTime": "2025-11-30T16:06:51.063Z",
157+
"time": 2435,
158+
"timings": {
159+
"blocked": -1,
160+
"connect": -1,
161+
"dns": -1,
162+
"receive": 0,
163+
"send": 0,
164+
"ssl": -1,
165+
"wait": 2435
166+
}
167+
}
168+
],
169+
"pages": [],
170+
"version": "1.2"
171+
}
172+
}

packages/traceloop-sdk/recordings/Test-AI-SDK-Agent-Integration-with-Recording_2039949225/should-propagate-agent-name-to-tool-call-spans_3577231859/recording.har

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"value": "application/json"
2121
}
2222
],
23-
"headersSize": 273,
23+
"headersSize": 165,
2424
"httpVersion": "HTTP/1.1",
2525
"method": "POST",
2626
"postData": {
@@ -36,7 +36,7 @@
3636
"content": {
3737
"mimeType": "application/json",
3838
"size": 2245,
39-
"text": "{\n \"id\": \"resp_0e754fd2dd3ca4a000692453dad96881a2b18b96c11135ab3f\",\n \"object\": \"response\",\n \"created_at\": 1763988442,\n \"status\": \"completed\",\n \"background\": false,\n \"billing\": {\n \"payer\": \"developer\"\n },\n \"error\": null,\n \"incomplete_details\": null,\n \"instructions\": null,\n \"max_output_tokens\": null,\n \"max_tool_calls\": null,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n \"output\": [\n {\n \"id\": \"fc_0e754fd2dd3ca4a000692453dbc09881a2a3ba7ee0f18e00bd\",\n \"type\": \"function_call\",\n \"status\": \"completed\",\n \"arguments\": \"{\\\"operation\\\":\\\"add\\\",\\\"a\\\":5,\\\"b\\\":3}\",\n \"call_id\": \"call_SebJXbaRXHEV4MBI8sUrXIQ4\",\n \"name\": \"calculate\"\n }\n ],\n \"parallel_tool_calls\": true,\n \"previous_response_id\": null,\n \"prompt_cache_key\": null,\n \"prompt_cache_retention\": null,\n \"reasoning\": {\n \"effort\": null,\n \"summary\": null\n },\n \"safety_identifier\": null,\n \"service_tier\": \"default\",\n \"store\": true,\n \"temperature\": 1.0,\n \"text\": {\n \"format\": {\n \"type\": \"text\"\n },\n \"verbosity\": \"medium\"\n },\n \"tool_choice\": \"auto\",\n \"tools\": [\n {\n \"type\": \"function\",\n \"description\": \"Perform basic mathematical calculations\",\n \"name\": \"calculate\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"operation\": {\n \"type\": \"string\",\n \"enum\": [\n \"add\",\n \"subtract\",\n \"multiply\",\n \"divide\"\n ],\n \"description\": \"The mathematical operation to perform\"\n },\n \"a\": {\n \"type\": \"number\",\n \"description\": \"First number\"\n },\n \"b\": {\n \"type\": \"number\",\n \"description\": \"Second number\"\n }\n },\n \"required\": [\n \"operation\",\n \"a\",\n \"b\"\n ],\n \"additionalProperties\": false\n },\n \"strict\": false\n }\n ],\n \"top_logprobs\": 0,\n \"top_p\": 1.0,\n \"truncation\": \"disabled\",\n \"usage\": {\n \"input_tokens\": 79,\n \"input_tokens_details\": {\n \"cached_tokens\": 0\n },\n \"output_tokens\": 22,\n \"output_tokens_details\": {\n \"reasoning_tokens\": 0\n },\n \"total_tokens\": 101\n },\n \"user\": null,\n \"metadata\": {}\n}"
39+
"text": "{\n \"id\": \"resp_06cd1796e6db213500692c69152cc8819597676548987937a6\",\n \"object\": \"response\",\n \"created_at\": 1764518165,\n \"status\": \"completed\",\n \"background\": false,\n \"billing\": {\n \"payer\": \"developer\"\n },\n \"error\": null,\n \"incomplete_details\": null,\n \"instructions\": null,\n \"max_output_tokens\": null,\n \"max_tool_calls\": null,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n \"output\": [\n {\n \"id\": \"fc_06cd1796e6db213500692c6915bfc481958fbfc020bb9bca71\",\n \"type\": \"function_call\",\n \"status\": \"completed\",\n \"arguments\": \"{\\\"operation\\\":\\\"add\\\",\\\"a\\\":5,\\\"b\\\":3}\",\n \"call_id\": \"call_aOLh0xzqYmJsdRu2SZCAjXGk\",\n \"name\": \"calculate\"\n }\n ],\n \"parallel_tool_calls\": true,\n \"previous_response_id\": null,\n \"prompt_cache_key\": null,\n \"prompt_cache_retention\": null,\n \"reasoning\": {\n \"effort\": null,\n \"summary\": null\n },\n \"safety_identifier\": null,\n \"service_tier\": \"default\",\n \"store\": true,\n \"temperature\": 1.0,\n \"text\": {\n \"format\": {\n \"type\": \"text\"\n },\n \"verbosity\": \"medium\"\n },\n \"tool_choice\": \"auto\",\n \"tools\": [\n {\n \"type\": \"function\",\n \"description\": \"Perform basic mathematical calculations\",\n \"name\": \"calculate\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"operation\": {\n \"type\": \"string\",\n \"enum\": [\n \"add\",\n \"subtract\",\n \"multiply\",\n \"divide\"\n ],\n \"description\": \"The mathematical operation to perform\"\n },\n \"a\": {\n \"type\": \"number\",\n \"description\": \"First number\"\n },\n \"b\": {\n \"type\": \"number\",\n \"description\": \"Second number\"\n }\n },\n \"required\": [\n \"operation\",\n \"a\",\n \"b\"\n ],\n \"additionalProperties\": false\n },\n \"strict\": false\n }\n ],\n \"top_logprobs\": 0,\n \"top_p\": 1.0,\n \"truncation\": \"disabled\",\n \"usage\": {\n \"input_tokens\": 79,\n \"input_tokens_details\": {\n \"cached_tokens\": 0\n },\n \"output_tokens\": 22,\n \"output_tokens_details\": {\n \"reasoning_tokens\": 0\n },\n \"total_tokens\": 101\n },\n \"user\": null,\n \"metadata\": {}\n}"
4040
},
4141
"cookies": [
4242
{
@@ -46,7 +46,7 @@
4646
"path": "/",
4747
"sameSite": "None",
4848
"secure": true,
49-
"value": "z_WEIpdzjXm_j82pEGjPUPhnguWZO_xLh5fJ5MhUC3U-1763988445029-0.0.1.1-604800000"
49+
"value": "N40DOLChO8bYrUpZbE8kW.gmAfTegj0z2o735W66OzA-1764518167404-0.0.1.1-604800000"
5050
}
5151
],
5252
"headers": [
@@ -60,7 +60,7 @@
6060
},
6161
{
6262
"name": "cf-ray",
63-
"value": "9a3903b48d891f5a-TLV"
63+
"value": "9a6b88639cf90bed-TLV"
6464
},
6565
{
6666
"name": "connection",
@@ -76,15 +76,15 @@
7676
},
7777
{
7878
"name": "date",
79-
"value": "Mon, 24 Nov 2025 12:47:25 GMT"
79+
"value": "Sun, 30 Nov 2025 15:56:07 GMT"
8080
},
8181
{
8282
"name": "openai-organization",
8383
"value": "traceloop"
8484
},
8585
{
8686
"name": "openai-processing-ms",
87-
"value": "2132"
87+
"value": "2157"
8888
},
8989
{
9090
"name": "openai-project",
@@ -100,7 +100,7 @@
100100
},
101101
{
102102
"name": "set-cookie",
103-
"value": "_cfuvid=z_WEIpdzjXm_j82pEGjPUPhnguWZO_xLh5fJ5MhUC3U-1763988445029-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None"
103+
"value": "_cfuvid=N40DOLChO8bYrUpZbE8kW.gmAfTegj0z2o735W66OzA-1764518167404-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None"
104104
},
105105
{
106106
"name": "strict-transport-security",
@@ -116,7 +116,7 @@
116116
},
117117
{
118118
"name": "x-envoy-upstream-service-time",
119-
"value": "2135"
119+
"value": "2160"
120120
},
121121
{
122122
"name": "x-ratelimit-limit-requests",
@@ -132,7 +132,7 @@
132132
},
133133
{
134134
"name": "x-ratelimit-remaining-tokens",
135-
"value": "149999702"
135+
"value": "149999705"
136136
},
137137
{
138138
"name": "x-ratelimit-reset-requests",
@@ -144,7 +144,7 @@
144144
},
145145
{
146146
"name": "x-request-id",
147-
"value": "req_72a75431374546598089e1714e871c10"
147+
"value": "req_2ecc43caa6014cb082a97679c52223bf"
148148
}
149149
],
150150
"headersSize": 958,
@@ -153,16 +153,16 @@
153153
"status": 200,
154154
"statusText": "OK"
155155
},
156-
"startedDateTime": "2025-11-24T12:47:22.157Z",
157-
"time": 2873,
156+
"startedDateTime": "2025-11-30T15:56:04.893Z",
157+
"time": 2441,
158158
"timings": {
159159
"blocked": -1,
160160
"connect": -1,
161161
"dns": -1,
162162
"receive": 0,
163163
"send": 0,
164164
"ssl": -1,
165-
"wait": 2873
165+
"wait": 2441
166166
}
167167
}
168168
],

0 commit comments

Comments
 (0)