From aa94fb2f831ef8a85e76d4b056811093dc4205cf Mon Sep 17 00:00:00 2001 From: sigoden Date: Tue, 11 Jun 2024 17:52:04 +0800 Subject: [PATCH] fix: infinite loop of function calls on poor LLM (#585) --- src/function.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/function.rs b/src/function.rs index 068cee0..b763dc2 100644 --- a/src/function.rs +++ b/src/function.rs @@ -28,6 +28,9 @@ pub fn eval_tool_calls( return Ok(output); } calls = ToolCall::dedup(calls); + if calls.is_empty() { + bail!("The request was aborted because an infinite loop of function calls was detected.") + } for call in calls { let result = call.eval(config)?; output.push(ToolCallResult::new(call, result));