tool-call: ensure there's always a non-empty tool call id (#12292)

This commit is contained in:
Olivier Chafik
2025-03-10 09:45:29 +00:00
committed by GitHub
parent 87c2630546
commit be421fc429
3 changed files with 11 additions and 1 deletions

View File

@ -751,7 +751,10 @@ struct server_task_result_cmpl_final : server_task_result {
{"name", tc.name},
{"arguments", tc.arguments},
}},
{"id", tc.id},
// Some templates generate and require an id (sometimes in a very specific format, e.g. Mistral Nemo).
// We only generate a random id for the ones that don't generate one by themselves
// (they also won't get to see it as their template likely doesn't use it, so it's all for the client)
{"id", tc.id.empty() ? gen_tool_call_id() : tc.id},
});
}
message["tool_calls"] = tool_calls;