Run OpenAI-compatible tool calls sent without an index or finished with stop

Merged
PU
11d ago
+173-4

Some OpenAI-compatible servers, Gemini among them, stream tool call deltas without an index. Streaming then fails with Undefined array key "index".

The same servers end a tool turn with finish_reason: "stop". Both prompt() and stream() then skip the tool calls and return empty text.

[!NOTE]
Tool calls now run when the turn finishes with stop. They are still discarded on length, because the arguments can be truncated.

Replaces #1159.