From 1d3bd8bb139120f0eae5daa9ca7b03538aca10b0 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Thu, 7 May 2026 17:43:23 +0800 Subject: [PATCH] chore(agent): log natural-stop candidate when no tool calls Add explicit response logging for the branch where the model returns finish=stop with zero tool calls. This makes it easier to identify the natural-stop path early in logs and correlate rounds that are likely to be treated as final-answer candidates by analyzeResponse. - include `tool_calls=0` in the no-tool summary log - emit a dedicated "Natural-stop candidate detected" info log when finish_reason is stop and no tool calls are present --- internal/agent/think.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/agent/think.go b/internal/agent/think.go index 1b1f1a44..8c4f899d 100644 --- a/internal/agent/think.go +++ b/internal/agent/think.go @@ -358,8 +358,14 @@ func (e *AgentEngine) callLLMWithRetry( logger.Infof(ctx, "[Agent][Round-%d] LLM responded: finish=%s, content=%d chars, tools=%v", round, response.FinishReason, len(response.Content), tcNames) } else { - logger.Infof(ctx, "[Agent][Round-%d] LLM responded: finish=%s, content=%d chars", + logger.Infof(ctx, "[Agent][Round-%d] LLM responded: finish=%s, content=%d chars, tool_calls=0", round, response.FinishReason, len(response.Content)) + // Early signal for natural-stop path: this round will be analyzed as a + // likely final answer (no tool call branch). + if response.FinishReason == "stop" { + logger.Infof(ctx, "[Agent][Round-%d] Natural-stop candidate detected (finish=stop, tool_calls=0, content=%d chars)", + round, len(response.Content)) + } } if response.Content != "" { preview := response.Content