ResponseHasToolCalls reports whether a response body (streaming buffer or non-streaming JSON) contains tool/function calls that require agent execution. When true, this is an intermediate response in a multi-turn conversation and NOT the final text answer — so CompletePoisonCycle should be deferred.
(buf []byte, format string)
| 11 | // When true, this is an intermediate response in a multi-turn conversation and |
| 12 | // NOT the final text answer — so CompletePoisonCycle should be deferred. |
| 13 | func ResponseHasToolCalls(buf []byte, format string) bool { |
| 14 | f := GetFormat(format) |
| 15 | if f == nil { |
| 16 | return false |
| 17 | } |
| 18 | return f.HasToolCalls(buf) |
| 19 | } |
| 20 | |
| 21 | // openAIHasToolCalls checks OpenAI Chat Completions format. |
| 22 | // Non-streaming: single JSON with choices[0].finish_reason. |