Repository navigation
Commit 52c3a4e
fix(litellm): suppress empty leading content delta so refusal keeps index 0
Per @seratch: rather than open an empty text part for a leading "" content
delta and then close/reindex it, drop that delta before it opens a text part.
The synthesized content-filter refusal then lands at content index 0 in both
the streamed events and response.completed, so raw-event replay and the final
response stay aligned (previously the refusal streamed at index 1 while the
completed response placed it at position 0).
The suppression is scoped to a leading empty ("") delta when no text part has
opened yet; empty deltas after real text keep their existing behavior. With the
empty part gone, the synthesis block's close/distinct-index logic is dead and
removed — the block now just announces the message and emits the refusal at the
first content index.
Tests updated to assert no text part / no output_text.delta is emitted and that
the refusal's streamed content_index (0) matches its position in
response.completed. Live-verified against Bedrock claude-fable-5: 0
output_text.delta, 1 output_item.added, one content_part.added
(ResponseOutputRefusal) at index 0, completed content[0] a single refusal.
Co-Authored-By: Claude Opus 4.8 <[email protected]>1 parent 728b951 commit 52c3a4e
2 files changed
Lines changed: 54 additions & 59 deletions
File tree
- src/agents/models
- tests/models
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
685 | 685 | | |
686 | 686 | | |
687 | 687 | | |
688 | | - | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
689 | 699 | | |
690 | 700 | | |
691 | 701 | | |
| |||
953 | 963 | | |
954 | 964 | | |
955 | 965 | | |
956 | | - | |
957 | | - | |
958 | | - | |
| 966 | + | |
959 | 967 | | |
960 | 968 | | |
961 | 969 | | |
962 | | - | |
963 | | - | |
964 | | - | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
965 | 976 | | |
966 | 977 | | |
967 | 978 | | |
968 | | - | |
969 | | - | |
970 | | - | |
971 | | - | |
972 | | - | |
973 | | - | |
974 | | - | |
975 | | - | |
976 | | - | |
977 | | - | |
978 | | - | |
979 | | - | |
980 | | - | |
981 | | - | |
982 | | - | |
983 | | - | |
984 | | - | |
985 | | - | |
986 | | - | |
987 | | - | |
988 | | - | |
989 | | - | |
990 | 979 | | |
991 | 980 | | |
992 | 981 | | |
993 | 982 | | |
994 | 983 | | |
995 | | - | |
996 | | - | |
997 | | - | |
998 | | - | |
999 | | - | |
1000 | | - | |
1001 | | - | |
1002 | | - | |
1003 | | - | |
1004 | | - | |
1005 | | - | |
1006 | | - | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
1013 | 999 | | |
1014 | 1000 | | |
1015 | 1001 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
| |||
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
| 503 | + | |
| 504 | + | |
507 | 505 | | |
508 | 506 | | |
509 | 507 | | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
510 | 515 | | |
511 | | - | |
512 | | - | |
513 | 516 | | |
514 | 517 | | |
515 | 518 | | |
| |||
518 | 521 | | |
519 | 522 | | |
520 | 523 | | |
521 | | - | |
522 | | - | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
523 | 532 | | |
524 | 533 | | |
525 | 534 | | |
| |||
0 commit comments