fix(ai): raise agent tool-call limit 8 -> 30

Multi-step hardware tasks (operate several ports, repeated read/write,
power-cycle waits) hit the old 8-round cap easily — e.g. "send help 3
times" needs 8 calls and stopped short of the final summary. 30 keeps
the runaway-loop guard while allowing normal workflows to finish.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-05 23:45:57 +08:00
co-authored by Claude Fable 5
parent 4820de22f8
commit d6135237e8
+3 -1
View File
@@ -14,7 +14,9 @@ public sealed class AgentHost
private readonly OpenAiChatClient _client; private readonly OpenAiChatClient _client;
private readonly AiTools _tools; private readonly AiTools _tools;
private readonly JsonArray _messages = new(); private readonly JsonArray _messages = new();
private const int MaxToolRounds = 8; // 單次 SendAsync 的工具呼叫輪數上限(防失控迴圈的保險)。硬體任務常需多輪
// (逐一操作多個 port、多次讀寫、power-cycle 等待…),故放寬到 30。
private const int MaxToolRounds = 30;
public event Action<string>? AssistantText; // 最終文字回應 public event Action<string>? AssistantText; // 最終文字回應
public event Action<string>? ToolActivity; // 「呼叫 serial_write …」之類過程 public event Action<string>? ToolActivity; // 「呼叫 serial_write …」之類過程