fix: include extracted text in web_fetch ForLLM response

The ForLLM field only returned a metadata summary ("Fetched N bytes from URL"),
causing the LLM to never see the actual page content. This led to repeated
tool calls on the same URL until max_tool_iterations was hit.

Fixes #388

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
JexLau 2026-02-18 06:22:47 +08:00
parent ba47892bcf
commit 8ddd74655f

View file

@ -476,8 +476,10 @@ func (t *WebFetchTool) Execute(ctx context.Context, args map[string]interface{})
resultJSON, _ := json.MarshalIndent(result, "", " ")
forLLM := fmt.Sprintf("Fetched %d bytes from %s (extractor: %s, truncated: %v)\n\n%s", len(text), urlStr, extractor, truncated, text)
return &ToolResult{
ForLLM: fmt.Sprintf("Fetched %d bytes from %s (extractor: %s, truncated: %v)", len(text), urlStr, extractor, truncated),
ForLLM: forLLM,
ForUser: string(resultJSON),
}
}