Skip to content

Commit 931326b

Browse files
authored
fix(mistral): add tool spans for completions (#381)
Create child TOOL spans for Mistral chat and agent tool calls in both complete and streaming paths. resolves #378
1 parent 6968fe5 commit 931326b

10 files changed

Lines changed: 1278 additions & 1 deletion
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
interactions:
2+
- request:
3+
body: '{"model":"mistral-small-latest","name":"braintrust-test-agent-1777662640208","instructions":"You
4+
are concise. Keep responses under five words."}'
5+
headers:
6+
Accept:
7+
- application/json
8+
Accept-Encoding:
9+
- gzip, deflate
10+
Connection:
11+
- keep-alive
12+
Content-Length:
13+
- '144'
14+
Host:
15+
- api.mistral.ai
16+
content-type:
17+
- application/json
18+
user-agent:
19+
- mistral-client-python/1.12.4
20+
method: POST
21+
uri: https://api.mistral.ai/v1/agents
22+
response:
23+
body:
24+
string: '{"instructions":"You are concise. Keep responses under five words.","tools":[],"completion_args":{"stop":null,"presence_penalty":null,"frequency_penalty":null,"temperature":null,"top_p":null,"max_tokens":null,"random_seed":null,"prediction":null,"response_format":null,"tool_choice":"auto","reasoning_effort":null},"guardrails":[],"model":"mistral-small-latest","name":"braintrust-test-agent-1777662640208","description":null,"handoffs":null,"metadata":null,"object":"agent","id":"ag_019de4f3414e7434ae6a78a856e4bafd","version":0,"versions":[],"created_at":"2026-05-01T19:10:40.491735Z","updated_at":"2026-05-01T19:10:40.491738Z","deployment_chat":false,"source":"api","version_message":null}'
25+
headers:
26+
CF-RAY:
27+
- 9f51166de93746b5-YYZ
28+
Connection:
29+
- keep-alive
30+
Content-Type:
31+
- application/json
32+
Date:
33+
- Fri, 01 May 2026 19:10:40 GMT
34+
Server:
35+
- cloudflare
36+
Strict-Transport-Security:
37+
- max-age=15552000; includeSubDomains; preload
38+
Transfer-Encoding:
39+
- chunked
40+
X-Content-Type-Options:
41+
- nosniff
42+
access-control-allow-origin:
43+
- '*'
44+
alt-svc:
45+
- h3=":443"; ma=86400
46+
cf-cache-status:
47+
- DYNAMIC
48+
content-length:
49+
- '692'
50+
mistral-correlation-id:
51+
- 019de4f3-40f5-7b12-9317-dc66b898f3b1
52+
set-cookie:
53+
- __cf_bm=IHhDeC7rRK6YDtNcGbJe0_M_e2cgUmbG0oloO5VpkTs-1777662640.3053465-1.0.1.1-jT.JFGuSHJXanjc2Djujkxfx4rE0vcXBs0Hb7OW8W1aNfTIroDsCn_2VrY9kF.m44eU7H8YSwkH.Yh4HOfasl7nS_glA7HOQdvyn2KBdzbcrC0uZkNMzZqcczWqIiCkm;
54+
HttpOnly; Secure; Path=/; Domain=mistral.ai; Expires=Fri, 01 May 2026 19:40:40
55+
GMT
56+
- _cfuvid=4.caIoynBFVOJU5CUbNRmeWN0aEZwc.d_BBtGYy0Ck8-1777662640.3053465-1.0.1.1-40ePzWEHHOdDI.y74_NIOYu42q283fv1RuXUVr3317E;
57+
HttpOnly; SameSite=None; Secure; Path=/; Domain=mistral.ai
58+
x-envoy-upstream-service-time:
59+
- '95'
60+
x-kong-proxy-latency:
61+
- '41'
62+
x-kong-request-id:
63+
- 019de4f3-40f5-7b12-9317-dc66b898f3b1
64+
x-kong-upstream-latency:
65+
- '96'
66+
status:
67+
code: 200
68+
message: OK
69+
- request:
70+
body: '{"messages":[{"content":"Use get_weather for Paris. Do not answer directly.","role":"user"}],"agent_id":"ag_019de4f3414e7434ae6a78a856e4bafd","max_tokens":100,"stream":false,"tools":[{"function":{"name":"get_weather","parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]},"description":"Get
71+
the weather for a city."},"type":"function"}],"tool_choice":"any"}'
72+
headers:
73+
Accept:
74+
- application/json
75+
Accept-Encoding:
76+
- gzip, deflate
77+
Connection:
78+
- keep-alive
79+
Content-Length:
80+
- '393'
81+
Cookie:
82+
- __cf_bm=IHhDeC7rRK6YDtNcGbJe0_M_e2cgUmbG0oloO5VpkTs-1777662640.3053465-1.0.1.1-jT.JFGuSHJXanjc2Djujkxfx4rE0vcXBs0Hb7OW8W1aNfTIroDsCn_2VrY9kF.m44eU7H8YSwkH.Yh4HOfasl7nS_glA7HOQdvyn2KBdzbcrC0uZkNMzZqcczWqIiCkm;
83+
_cfuvid=4.caIoynBFVOJU5CUbNRmeWN0aEZwc.d_BBtGYy0Ck8-1777662640.3053465-1.0.1.1-40ePzWEHHOdDI.y74_NIOYu42q283fv1RuXUVr3317E
84+
Host:
85+
- api.mistral.ai
86+
content-type:
87+
- application/json
88+
user-agent:
89+
- mistral-client-python/1.12.4
90+
method: POST
91+
uri: https://api.mistral.ai/v1/agents/completions
92+
response:
93+
body:
94+
string: '{"id":"78cf63e6a47f4e9d8997f88f9d5d09a0","created":1777662640,"model":"mistral-small-latest","usage":{"prompt_tokens":100,"total_tokens":112,"completion_tokens":12,"prompt_tokens_details":{"cached_tokens":0}},"object":"chat.completion","choices":[{"index":0,"finish_reason":"tool_calls","message":{"role":"assistant","tool_calls":[{"id":"HpwsuA761","function":{"name":"get_weather","arguments":"{\"city\":
95+
\"Paris\"}"},"index":0}],"content":""}}]}'
96+
headers:
97+
CF-RAY:
98+
- 9f5116709c2cac7c-YYZ
99+
Connection:
100+
- keep-alive
101+
Content-Type:
102+
- application/json
103+
Date:
104+
- Fri, 01 May 2026 19:10:41 GMT
105+
Server:
106+
- cloudflare
107+
Strict-Transport-Security:
108+
- max-age=15552000; includeSubDomains; preload
109+
Transfer-Encoding:
110+
- chunked
111+
X-Content-Type-Options:
112+
- nosniff
113+
access-control-allow-origin:
114+
- '*'
115+
alt-svc:
116+
- h3=":443"; ma=86400
117+
cf-cache-status:
118+
- DYNAMIC
119+
content-length:
120+
- '447'
121+
mistral-correlation-id:
122+
- 019de4f3-42a6-7bcb-914d-147bd2dfa3ba
123+
x-envoy-upstream-service-time:
124+
- '285'
125+
x-kong-proxy-latency:
126+
- '13'
127+
x-kong-request-id:
128+
- 019de4f3-42a6-7bcb-914d-147bd2dfa3ba
129+
x-kong-upstream-latency:
130+
- '285'
131+
x-ratelimit-limit-req-minute:
132+
- '400'
133+
x-ratelimit-limit-tokens-minute:
134+
- '1500000'
135+
x-ratelimit-remaining-req-minute:
136+
- '394'
137+
x-ratelimit-remaining-tokens-minute:
138+
- '1499440'
139+
x-ratelimit-tokens-query-cost:
140+
- '112'
141+
status:
142+
code: 200
143+
message: OK
144+
- request:
145+
body: ''
146+
headers:
147+
Accept:
148+
- application/json
149+
Accept-Encoding:
150+
- gzip, deflate
151+
Connection:
152+
- keep-alive
153+
Cookie:
154+
- __cf_bm=IHhDeC7rRK6YDtNcGbJe0_M_e2cgUmbG0oloO5VpkTs-1777662640.3053465-1.0.1.1-jT.JFGuSHJXanjc2Djujkxfx4rE0vcXBs0Hb7OW8W1aNfTIroDsCn_2VrY9kF.m44eU7H8YSwkH.Yh4HOfasl7nS_glA7HOQdvyn2KBdzbcrC0uZkNMzZqcczWqIiCkm;
155+
_cfuvid=4.caIoynBFVOJU5CUbNRmeWN0aEZwc.d_BBtGYy0Ck8-1777662640.3053465-1.0.1.1-40ePzWEHHOdDI.y74_NIOYu42q283fv1RuXUVr3317E
156+
Host:
157+
- api.mistral.ai
158+
user-agent:
159+
- mistral-client-python/1.12.4
160+
method: DELETE
161+
uri: https://api.mistral.ai/v1/agents/ag_019de4f3414e7434ae6a78a856e4bafd
162+
response:
163+
body:
164+
string: ''
165+
headers:
166+
CF-RAY:
167+
- 9f5116752c34f80e-YYZ
168+
Connection:
169+
- keep-alive
170+
Date:
171+
- Fri, 01 May 2026 19:10:41 GMT
172+
Server:
173+
- cloudflare
174+
Strict-Transport-Security:
175+
- max-age=15552000; includeSubDomains; preload
176+
X-Content-Type-Options:
177+
- nosniff
178+
access-control-allow-origin:
179+
- '*'
180+
alt-svc:
181+
- h3=":443"; ma=86400
182+
cf-cache-status:
183+
- DYNAMIC
184+
mistral-correlation-id:
185+
- 019de4f3-4579-71f1-8652-a0ef8f391026
186+
x-envoy-upstream-service-time:
187+
- '70'
188+
x-kong-proxy-latency:
189+
- '14'
190+
x-kong-request-id:
191+
- 019de4f3-4579-71f1-8652-a0ef8f391026
192+
x-kong-upstream-latency:
193+
- '71'
194+
status:
195+
code: 204
196+
message: No Content
197+
version: 1
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
interactions:
2+
- request:
3+
body: '{"model":"mistral-small-latest","name":"braintrust-test-agent-1777662671943","instructions":"You
4+
are concise. Keep responses under five words."}'
5+
headers:
6+
Accept:
7+
- application/json
8+
Accept-Encoding:
9+
- gzip, deflate
10+
Connection:
11+
- keep-alive
12+
Content-Length:
13+
- '144'
14+
Host:
15+
- api.mistral.ai
16+
content-type:
17+
- application/json
18+
user-agent:
19+
- mistral-client-python/1.12.4
20+
method: POST
21+
uri: https://api.mistral.ai/v1/agents
22+
response:
23+
body:
24+
string: '{"instructions":"You are concise. Keep responses under five words.","tools":[],"completion_args":{"stop":null,"presence_penalty":null,"frequency_penalty":null,"temperature":null,"top_p":null,"max_tokens":null,"random_seed":null,"prediction":null,"response_format":null,"tool_choice":"auto","reasoning_effort":null},"guardrails":[],"model":"mistral-small-latest","name":"braintrust-test-agent-1777662671943","description":null,"handoffs":null,"metadata":null,"object":"agent","id":"ag_019de4f3bd267493989dd4f850ceb55b","version":0,"versions":[],"created_at":"2026-05-01T19:11:12.191782Z","updated_at":"2026-05-01T19:11:12.191786Z","deployment_chat":false,"source":"api","version_message":null}'
25+
headers:
26+
CF-RAY:
27+
- 9f51173449b5cceb-YYZ
28+
Connection:
29+
- keep-alive
30+
Content-Type:
31+
- application/json
32+
Date:
33+
- Fri, 01 May 2026 19:11:12 GMT
34+
Server:
35+
- cloudflare
36+
Strict-Transport-Security:
37+
- max-age=15552000; includeSubDomains; preload
38+
Transfer-Encoding:
39+
- chunked
40+
X-Content-Type-Options:
41+
- nosniff
42+
access-control-allow-origin:
43+
- '*'
44+
alt-svc:
45+
- h3=":443"; ma=86400
46+
cf-cache-status:
47+
- DYNAMIC
48+
content-length:
49+
- '692'
50+
mistral-correlation-id:
51+
- 019de4f3-bce2-7629-b11e-cc23c1380f13
52+
set-cookie:
53+
- __cf_bm=mrhYeiViro6wHtnqEpjGd7hLPJ9mRg8F4nnNLW3ccTY-1777662672.0451913-1.0.1.1-0IRI6JbggwIc5aakVXrqZQm5PPHM.6xVcr90B638zB0obwP4lOxct1IbX4krwFGQFLq46M48D4NWvuD9p8r1RfcGdtWw4nZ.bXBhK9KkndJ_V5.E7_Kh8Kra7DFrwRjI;
54+
HttpOnly; Secure; Path=/; Domain=mistral.ai; Expires=Fri, 01 May 2026 19:41:12
55+
GMT
56+
- _cfuvid=n4cckRYwtN0jFPxsF.RUuDU.CMxMRnq6LwMIFs0BFRU-1777662672.0451913-1.0.1.1-cGhPr72ahCa8TzVXUwb_f.ZXxxvaf3e3FaY7n6CAEOk;
57+
HttpOnly; SameSite=None; Secure; Path=/; Domain=mistral.ai
58+
x-envoy-upstream-service-time:
59+
- '90'
60+
x-kong-proxy-latency:
61+
- '20'
62+
x-kong-request-id:
63+
- 019de4f3-bce2-7629-b11e-cc23c1380f13
64+
x-kong-upstream-latency:
65+
- '92'
66+
status:
67+
code: 200
68+
message: OK
69+
- request:
70+
body: '{"messages":[{"content":"Use get_weather for Paris. Do not answer directly.","role":"user"}],"agent_id":"ag_019de4f3bd267493989dd4f850ceb55b","max_tokens":100,"stream":true,"tools":[{"function":{"name":"get_weather","parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]},"description":"Get
71+
the weather for a city."},"type":"function"}],"tool_choice":"any"}'
72+
headers:
73+
Accept:
74+
- text/event-stream
75+
Accept-Encoding:
76+
- gzip, deflate
77+
Connection:
78+
- keep-alive
79+
Content-Length:
80+
- '392'
81+
Cookie:
82+
- __cf_bm=mrhYeiViro6wHtnqEpjGd7hLPJ9mRg8F4nnNLW3ccTY-1777662672.0451913-1.0.1.1-0IRI6JbggwIc5aakVXrqZQm5PPHM.6xVcr90B638zB0obwP4lOxct1IbX4krwFGQFLq46M48D4NWvuD9p8r1RfcGdtWw4nZ.bXBhK9KkndJ_V5.E7_Kh8Kra7DFrwRjI;
83+
_cfuvid=n4cckRYwtN0jFPxsF.RUuDU.CMxMRnq6LwMIFs0BFRU-1777662672.0451913-1.0.1.1-cGhPr72ahCa8TzVXUwb_f.ZXxxvaf3e3FaY7n6CAEOk
84+
Host:
85+
- api.mistral.ai
86+
content-type:
87+
- application/json
88+
user-agent:
89+
- mistral-client-python/1.12.4
90+
method: POST
91+
uri: https://api.mistral.ai/v1/agents/completions
92+
response:
93+
body:
94+
string: 'data: {"id":"f0045c73780a49f9baf96638d0c1635b","object":"chat.completion.chunk","created":1777662672,"model":"mistral-small-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}
95+
96+
97+
data: {"id":"f0045c73780a49f9baf96638d0c1635b","object":"chat.completion.chunk","created":1777662672,"model":"mistral-small-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"ykk9sb1fw","function":{"name":"get_weather","arguments":"{\"city\":
98+
\"Paris\"}"},"index":0}]},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":100,"total_tokens":112,"completion_tokens":12,"prompt_tokens_details":{"cached_tokens":80}},"p":"ab"}
99+
100+
101+
data: [DONE]
102+
103+
104+
'
105+
headers:
106+
CF-RAY:
107+
- 9f5117364caf78a5-YYZ
108+
Connection:
109+
- keep-alive
110+
Content-Type:
111+
- text/event-stream; charset=utf-8
112+
Date:
113+
- Fri, 01 May 2026 19:11:13 GMT
114+
Server:
115+
- cloudflare
116+
Strict-Transport-Security:
117+
- max-age=15552000; includeSubDomains; preload
118+
Transfer-Encoding:
119+
- chunked
120+
X-Content-Type-Options:
121+
- nosniff
122+
access-control-allow-origin:
123+
- '*'
124+
alt-svc:
125+
- h3=":443"; ma=86400
126+
cf-cache-status:
127+
- DYNAMIC
128+
mistral-correlation-id:
129+
- 019de4f3-be2b-7b2e-8400-692abd2de685
130+
x-envoy-upstream-service-time:
131+
- '299'
132+
x-kong-proxy-latency:
133+
- '271'
134+
x-kong-request-id:
135+
- 019de4f3-be2b-7b2e-8400-692abd2de685
136+
x-kong-upstream-latency:
137+
- '300'
138+
status:
139+
code: 200
140+
message: OK
141+
- request:
142+
body: ''
143+
headers:
144+
Accept:
145+
- application/json
146+
Accept-Encoding:
147+
- gzip, deflate
148+
Connection:
149+
- keep-alive
150+
Cookie:
151+
- __cf_bm=mrhYeiViro6wHtnqEpjGd7hLPJ9mRg8F4nnNLW3ccTY-1777662672.0451913-1.0.1.1-0IRI6JbggwIc5aakVXrqZQm5PPHM.6xVcr90B638zB0obwP4lOxct1IbX4krwFGQFLq46M48D4NWvuD9p8r1RfcGdtWw4nZ.bXBhK9KkndJ_V5.E7_Kh8Kra7DFrwRjI;
152+
_cfuvid=n4cckRYwtN0jFPxsF.RUuDU.CMxMRnq6LwMIFs0BFRU-1777662672.0451913-1.0.1.1-cGhPr72ahCa8TzVXUwb_f.ZXxxvaf3e3FaY7n6CAEOk
153+
Host:
154+
- api.mistral.ai
155+
user-agent:
156+
- mistral-client-python/1.12.4
157+
method: DELETE
158+
uri: https://api.mistral.ai/v1/agents/ag_019de4f3bd267493989dd4f850ceb55b
159+
response:
160+
body:
161+
string: ''
162+
headers:
163+
CF-RAY:
164+
- 9f51173f188cc109-YYZ
165+
Connection:
166+
- keep-alive
167+
Date:
168+
- Fri, 01 May 2026 19:11:13 GMT
169+
Server:
170+
- cloudflare
171+
Strict-Transport-Security:
172+
- max-age=15552000; includeSubDomains; preload
173+
X-Content-Type-Options:
174+
- nosniff
175+
access-control-allow-origin:
176+
- '*'
177+
alt-svc:
178+
- h3=":443"; ma=86400
179+
cf-cache-status:
180+
- DYNAMIC
181+
mistral-correlation-id:
182+
- 019de4f3-c3a8-7592-bba9-1a048f558172
183+
x-envoy-upstream-service-time:
184+
- '68'
185+
x-kong-proxy-latency:
186+
- '22'
187+
x-kong-request-id:
188+
- 019de4f3-c3a8-7592-bba9-1a048f558172
189+
x-kong-upstream-latency:
190+
- '69'
191+
status:
192+
code: 204
193+
message: No Content
194+
version: 1

0 commit comments

Comments
 (0)