fix: AI loop prevention (no tools on last iteration), calendar button first, mail filter in toolbar, AI folder rename query invalidation
Check Cross-Plugin Imports / check (push) Has been cancelled
Check Cross-Plugin Imports / check (push) Has been cancelled
This commit is contained in:
@@ -451,9 +451,12 @@ async def stream_chat(
|
||||
# Agent loop: LLM → tool calls → execute → feed back → repeat
|
||||
max_iterations = 5
|
||||
for iteration in range(max_iterations):
|
||||
# Add tools to params if available
|
||||
if tool_schemas:
|
||||
# Add tools to params if available, but NOT on the last iteration
|
||||
# to force the LLM to give a final answer instead of looping
|
||||
if tool_schemas and iteration < max_iterations - 1:
|
||||
params["tools"] = tool_schemas
|
||||
elif "tools" in params:
|
||||
del params["tools"]
|
||||
|
||||
# Stream LLM response
|
||||
collected_content = ""
|
||||
|
||||
Reference in New Issue
Block a user