Files
pentagi/backend/pkg/cast
Osamaali313 36872809f1 fix(cast): delete pruned tool-call parts in reverse to avoid index shift
NewBodyPair collects the indices of ToolCall parts with a nil
FunctionCall into partsToDelete, then deletes them in a forward loop
using those pre-collected ascending indices. Each deletion shifts every
later element left by one, so with two or more collected indices the
second and subsequent deletions remove the wrong elements: a valid
TextContent can be dropped while an invalid nil-FunctionCall tool call
survives into the message chain (feeding malformed messages downstream).

Iterate the collected indices in reverse so earlier indices stay valid
during deletion. Adds a regression test covering two leading
nil-FunctionCall tool calls followed by a text part.
2026-07-06 00:02:03 +03:00
..
2026-03-26 06:16:07 +03:00