Skip to content

Commit b2af9a2

Browse files
authored
fix(agent): Add gen_ai.agent.name span attribute (#737)
1 parent fb23391 commit b2af9a2

File tree

10 files changed

+1070
-4
lines changed

10 files changed

+1070
-4
lines changed

packages/ai-semantic-conventions/src/SemanticAttributes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export const SpanAttributes = {
2828
LLM_USAGE_PROMPT_TOKENS: "gen_ai.usage.prompt_tokens",
2929
LLM_USAGE_COMPLETION_TOKENS: "gen_ai.usage.completion_tokens",
3030

31+
GEN_AI_AGENT_NAME: "gen_ai.agent.name",
32+
3133
// LLM
3234
LLM_REQUEST_TYPE: "llm.request.type",
3335
LLM_USAGE_TOTAL_TOKENS: "llm.usage.total_tokens",

packages/sample-app/src/sample_vercel_ai_tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const searchRestaurants = tool({
114114
});
115115

116116
async function planTrip(destination: string) {
117-
return await traceloop.withWorkflow(
117+
return await traceloop.withAgent(
118118
{ name: "plan_trip" },
119119
async () => {
120120
console.log(`\n🌟 Planning a trip to ${destination}...\n`);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
{
2+
"log": {
3+
"_recordingName": "Test Agent Decorator/should create spans for agents using decoration syntax",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.6"
8+
},
9+
"entries": [
10+
{
11+
"_id": "80b48c70cae76a3c38b9af59d5273e33",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 139,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "content-length",
21+
"value": "139"
22+
},
23+
{
24+
"_fromType": "array",
25+
"name": "accept",
26+
"value": "application/json"
27+
},
28+
{
29+
"_fromType": "array",
30+
"name": "content-type",
31+
"value": "application/json"
32+
},
33+
{
34+
"_fromType": "array",
35+
"name": "user-agent",
36+
"value": "OpenAI/JS 4.38.3"
37+
},
38+
{
39+
"_fromType": "array",
40+
"name": "x-stainless-lang",
41+
"value": "js"
42+
},
43+
{
44+
"_fromType": "array",
45+
"name": "x-stainless-package-version",
46+
"value": "4.38.3"
47+
},
48+
{
49+
"_fromType": "array",
50+
"name": "x-stainless-os",
51+
"value": "MacOS"
52+
},
53+
{
54+
"_fromType": "array",
55+
"name": "x-stainless-arch",
56+
"value": "arm64"
57+
},
58+
{
59+
"_fromType": "array",
60+
"name": "x-stainless-runtime",
61+
"value": "node"
62+
},
63+
{
64+
"_fromType": "array",
65+
"name": "x-stainless-runtime-version",
66+
"value": "v20.11.1"
67+
},
68+
{
69+
"_fromType": "array",
70+
"name": "accept-encoding",
71+
"value": "gzip,deflate"
72+
},
73+
{
74+
"name": "host",
75+
"value": "api.openai.com"
76+
}
77+
],
78+
"headersSize": 583,
79+
"httpVersion": "HTTP/1.1",
80+
"method": "POST",
81+
"postData": {
82+
"mimeType": "application/json",
83+
"params": [],
84+
"text": "{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Tell me a joke about OpenTelemetry\"\n }\n ],\n \"model\": \"gpt-3.5-turbo\"\n}"
85+
},
86+
"queryString": [],
87+
"url": "https://api.openai.com/v1/chat/completions"
88+
},
89+
"response": {
90+
"bodySize": 651,
91+
"content": {
92+
"encoding": "base64",
93+
"mimeType": "application/json",
94+
"size": 651,
95+
"text": "[\"H4sIAAAAAAAAAwAAAP//\",\"jFLLjhMxELzPVzS+cElWSdjsIxcE7AkOgIS0CLQa9dg9M816bK/dwxJW+XfkyWMSHhIXH7q6yt1V/VQAKDZqBUq3KLoLdvrm6ub8nf18k17Rdf1gq2jslw8/w+Pb2cPHWzXJDF99Iy171pn2XbAk7N0W1pFQKKvOL5cXs8vF1fXFAHTekM20Jsj0xdlyKn2s/HQ2Xyx3zNazpqRW8LUAAHga3jyjM/RDrWA22Vc6SgkbUqtDE4CK3uaKwpQ4CTpRkxHU3gm5Yezbdg2GDUhL8D6Q+0SWOpK4BstVxLiGKhLeQx/gkaUFlgQNR1tHJmdewmvS2CcCFtC+t8Y9F2jRGUuAEMliNiO1vKOjtSAtClTYNNjQs+OxItV9wmyL6609AtA5L1ulbMjdDtkcLLC+CdFX6TeqqtlxastImLzL6ybxQQ3opgC4G6zuT9xTIfouSCn+nobv5sutnBrDHcHFHhQvaMf6+S6eU7XSkCDbdBSV0qhbMiNzzBV7w/4IKI52/nOYv2lv92bX/I/8CGhNQciUIZJhfbrw2BYpn/6/2g4eDwOrRPE7ayqFKeYcDNXY2+1RqrROQl1Zs2sohsjDZeYci03xCwAA//8DAEaTkYeYAwAA\"]"
96+
},
97+
"cookies": [
98+
{
99+
"domain": ".api.openai.com",
100+
"expires": "2025-08-24T22:31:37.000Z",
101+
"httpOnly": true,
102+
"name": "__cf_bm",
103+
"path": "/",
104+
"sameSite": "None",
105+
"secure": true,
106+
"value": ".o0a7QV1g5p2PGVThh2GmiCx5a8.gEUKTV5wQkJcV2o-1756072897-1.0.1.1-p53oAolAr8UafMy5McpEJ9rhTr5Z82LsQPQVeQ5Wca5wKQEq9kaa9EnemekZ6_KBaRWxhl5F.Kf4qkjUGsFC5a3LGZVtl9qnhZompi2UvS0"
107+
},
108+
{
109+
"domain": ".api.openai.com",
110+
"httpOnly": true,
111+
"name": "_cfuvid",
112+
"path": "/",
113+
"sameSite": "None",
114+
"secure": true,
115+
"value": "YH._SGFPHKE16IZLGfcgZL0Vqk..kuHrGz0kglvAD94-1756072897170-0.0.1.1-604800000"
116+
}
117+
],
118+
"headers": [
119+
{
120+
"name": "date",
121+
"value": "Sun, 24 Aug 2025 22:01:37 GMT"
122+
},
123+
{
124+
"name": "content-type",
125+
"value": "application/json"
126+
},
127+
{
128+
"name": "transfer-encoding",
129+
"value": "chunked"
130+
},
131+
{
132+
"name": "connection",
133+
"value": "keep-alive"
134+
},
135+
{
136+
"name": "access-control-expose-headers",
137+
"value": "X-Request-ID"
138+
},
139+
{
140+
"name": "openai-organization",
141+
"value": "traceloop"
142+
},
143+
{
144+
"name": "openai-processing-ms",
145+
"value": "334"
146+
},
147+
{
148+
"name": "openai-project",
149+
"value": "proj_tzz1TbPPOXaf6j9tEkVUBIAa"
150+
},
151+
{
152+
"name": "openai-version",
153+
"value": "2020-10-01"
154+
},
155+
{
156+
"name": "x-envoy-upstream-service-time",
157+
"value": "414"
158+
},
159+
{
160+
"name": "x-ratelimit-limit-requests",
161+
"value": "10000"
162+
},
163+
{
164+
"name": "x-ratelimit-limit-tokens",
165+
"value": "50000000"
166+
},
167+
{
168+
"name": "x-ratelimit-remaining-requests",
169+
"value": "9999"
170+
},
171+
{
172+
"name": "x-ratelimit-remaining-tokens",
173+
"value": "49999989"
174+
},
175+
{
176+
"name": "x-ratelimit-reset-requests",
177+
"value": "6ms"
178+
},
179+
{
180+
"name": "x-ratelimit-reset-tokens",
181+
"value": "0s"
182+
},
183+
{
184+
"name": "x-request-id",
185+
"value": "req_fc8ecede554a4503985a45721f1b8aa9"
186+
},
187+
{
188+
"name": "cf-cache-status",
189+
"value": "DYNAMIC"
190+
},
191+
{
192+
"_fromType": "array",
193+
"name": "set-cookie",
194+
"value": "__cf_bm=.o0a7QV1g5p2PGVThh2GmiCx5a8.gEUKTV5wQkJcV2o-1756072897-1.0.1.1-p53oAolAr8UafMy5McpEJ9rhTr5Z82LsQPQVeQ5Wca5wKQEq9kaa9EnemekZ6_KBaRWxhl5F.Kf4qkjUGsFC5a3LGZVtl9qnhZompi2UvS0; path=/; expires=Sun, 24-Aug-25 22:31:37 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None"
195+
},
196+
{
197+
"_fromType": "array",
198+
"name": "set-cookie",
199+
"value": "_cfuvid=YH._SGFPHKE16IZLGfcgZL0Vqk..kuHrGz0kglvAD94-1756072897170-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None"
200+
},
201+
{
202+
"name": "strict-transport-security",
203+
"value": "max-age=31536000; includeSubDomains; preload"
204+
},
205+
{
206+
"name": "x-content-type-options",
207+
"value": "nosniff"
208+
},
209+
{
210+
"name": "server",
211+
"value": "cloudflare"
212+
},
213+
{
214+
"name": "cf-ray",
215+
"value": "97462113aa47c224-TLV"
216+
},
217+
{
218+
"name": "content-encoding",
219+
"value": "gzip"
220+
},
221+
{
222+
"name": "alt-svc",
223+
"value": "h3=\":443\"; ma=86400"
224+
}
225+
],
226+
"headersSize": 1294,
227+
"httpVersion": "HTTP/1.1",
228+
"redirectURL": "",
229+
"status": 200,
230+
"statusText": "OK"
231+
},
232+
"startedDateTime": "2025-08-24T22:01:36.384Z",
233+
"time": 612,
234+
"timings": {
235+
"blocked": -1,
236+
"connect": -1,
237+
"dns": -1,
238+
"receive": 0,
239+
"send": 0,
240+
"ssl": -1,
241+
"wait": 612
242+
}
243+
}
244+
],
245+
"pages": [],
246+
"version": "1.2"
247+
}
248+
}

0 commit comments

Comments
 (0)