Commit 94f5037
committed
Fix infinite tool-call loop from over-aggressive trailing-message drop
The unconditional trailing-message drop introduced in 0.2.2 removed
assistant messages with pending (non-completed) tool calls. The model
then re-issued the tool call on the next turn, which produced another
trailing assistant+tool message, which got dropped again — infinite loop.
Fix: check each trailing message for pending tool parts before dropping.
If a pending tool part is found, stop dropping (with a warning log) rather
than removing the in-progress invocation. Completed tool parts are still
safe to drop.1 parent 1cb90cc commit 94f5037
2 files changed
+16
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | | - | |
399 | | - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
400 | 402 | | |
401 | 403 | | |
402 | 404 | | |
403 | 405 | | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
404 | 417 | | |
405 | 418 | | |
406 | 419 | | |
| |||
0 commit comments