From d6135237e820f63c87ebe49521e951977475a631 Mon Sep 17 00:00:00 2001 From: ETWen Date: Sun, 5 Jul 2026 23:45:57 +0800 Subject: [PATCH] fix(ai): raise agent tool-call limit 8 -> 30 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/ETTerms/Ai/AgentHost.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ETTerms/Ai/AgentHost.cs b/src/ETTerms/Ai/AgentHost.cs index 8ba5112..5621242 100644 --- a/src/ETTerms/Ai/AgentHost.cs +++ b/src/ETTerms/Ai/AgentHost.cs @@ -14,7 +14,9 @@ public sealed class AgentHost private readonly OpenAiChatClient _client; private readonly AiTools _tools; private readonly JsonArray _messages = new(); - private const int MaxToolRounds = 8; + // 單次 SendAsync 的工具呼叫輪數上限(防失控迴圈的保險)。硬體任務常需多輪 + // (逐一操作多個 port、多次讀寫、power-cycle 等待…),故放寬到 30。 + private const int MaxToolRounds = 30; public event Action? AssistantText; // 最終文字回應 public event Action? ToolActivity; // 「呼叫 serial_write …」之類過程