From f8936ec47c95e4147116a2d497e5b94a2d7c99ba Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Thu, 12 Mar 2026 17:10:41 -0700 Subject: [PATCH] Truncate web_search and fetch_webpage tools to 8192 tokens --- user_data/tools/web_search.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_data/tools/web_search.py b/user_data/tools/web_search.py index 8923eab0..46a45a8c 100644 --- a/user_data/tools/web_search.py +++ b/user_data/tools/web_search.py @@ -1,4 +1,4 @@ -from modules.web_search import perform_web_search +from modules.web_search import perform_web_search, truncate_content_by_tokens tool = { "type": "function", @@ -22,6 +22,6 @@ def execute(arguments): output = [] for r in results: if r and r["content"].strip(): - output.append({"title": r["title"], "url": r["url"], "content": r["content"][:4000]}) + output.append({"title": r["title"], "url": r["url"], "content": truncate_content_by_tokens(r["content"])}) return output if output else [{"error": "No results found."}]