Commit ff8bc9e
fix: parallel tool calls by deferring citation instructions (#397)
* Fix parallel tool calls by deferring citation instructions
For parallel tool calls (e.g., multiple web searches), all providers
(OpenAI, Anthropic, Gemini) require tool results to be consecutive
after the assistant message with tool_calls.
Previously, citation instructions were added immediately after each
tool result, which broke the consecutive sequence:
- tool result 1
- system message (citation) <-- breaks sequence
- tool result 2
Now, citation instructions are collected during tool execution and
added AFTER all tool results:
- tool result 1
- tool result 2
- system message (citation)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* combine all instructions into one system prompt message
* add draining/system prompt updates for mulitple types of tool call with multi-turn
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent beed835 commit ff8bc9e
1 file changed
Lines changed: 31 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1210 | 1210 | | |
1211 | 1211 | | |
1212 | 1212 | | |
1213 | | - | |
| 1213 | + | |
| 1214 | + | |
1214 | 1215 | | |
1215 | 1216 | | |
1216 | 1217 | | |
1217 | 1218 | | |
1218 | 1219 | | |
1219 | 1220 | | |
1220 | 1221 | | |
| 1222 | + | |
1221 | 1223 | | |
1222 | 1224 | | |
1223 | 1225 | | |
1224 | 1226 | | |
1225 | 1227 | | |
1226 | 1228 | | |
1227 | 1229 | | |
1228 | | - | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
1229 | 1239 | | |
1230 | 1240 | | |
1231 | 1241 | | |
1232 | 1242 | | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
1233 | 1254 | | |
1234 | 1255 | | |
1235 | 1256 | | |
| |||
1239 | 1260 | | |
1240 | 1261 | | |
1241 | 1262 | | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
1242 | 1267 | | |
1243 | 1268 | | |
1244 | 1269 | | |
1245 | 1270 | | |
1246 | 1271 | | |
1247 | 1272 | | |
| 1273 | + | |
1248 | 1274 | | |
1249 | 1275 | | |
1250 | 1276 | | |
| |||
1388 | 1414 | | |
1389 | 1415 | | |
1390 | 1416 | | |
1391 | | - | |
| 1417 | + | |
| 1418 | + | |
1392 | 1419 | | |
1393 | | - | |
1394 | | - | |
1395 | | - | |
1396 | | - | |
1397 | | - | |
1398 | | - | |
| 1420 | + | |
1399 | 1421 | | |
1400 | 1422 | | |
1401 | 1423 | | |
| |||
0 commit comments