mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-13 08:14:58 -05:00
fix(chat/tools): remove hard output truncation from sandbox and web_fetch
The SDK already handles oversized tool output by writing to tool-results files and reading back via MCP. Our 50K char truncation was cutting off output before the agent could see it — the SDK's mechanism is the proper way to handle large results.
This commit is contained in:
@@ -16,8 +16,6 @@ import shutil
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Output limits — prevent blowing up LLM context
|
||||
_MAX_OUTPUT_CHARS = 50_000
|
||||
_DEFAULT_TIMEOUT = 30
|
||||
_MAX_TIMEOUT = 120
|
||||
|
||||
@@ -253,8 +251,8 @@ async def run_sandboxed(
|
||||
stdout_bytes, stderr_bytes = await asyncio.wait_for(
|
||||
proc.communicate(), timeout=timeout
|
||||
)
|
||||
stdout = stdout_bytes.decode("utf-8", errors="replace")[:_MAX_OUTPUT_CHARS]
|
||||
stderr = stderr_bytes.decode("utf-8", errors="replace")[:_MAX_OUTPUT_CHARS]
|
||||
stdout = stdout_bytes.decode("utf-8", errors="replace")
|
||||
stderr = stderr_bytes.decode("utf-8", errors="replace")
|
||||
return stdout, stderr, proc.returncode or 0, False
|
||||
except asyncio.TimeoutError:
|
||||
proc.kill()
|
||||
|
||||
@@ -19,7 +19,6 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
# Limits
|
||||
_MAX_CONTENT_BYTES = 102_400 # 100 KB download cap
|
||||
_MAX_OUTPUT_CHARS = 50_000 # 50K char truncation for LLM context
|
||||
_REQUEST_TIMEOUT = aiohttp.ClientTimeout(total=15)
|
||||
|
||||
# Content types we'll read as text
|
||||
@@ -141,16 +140,12 @@ class WebFetchTool(BaseTool):
|
||||
if extract_text and "html" in content_type.lower():
|
||||
text = _html_to_text(text)
|
||||
|
||||
truncated = len(text) > _MAX_OUTPUT_CHARS
|
||||
if truncated:
|
||||
text = text[:_MAX_OUTPUT_CHARS]
|
||||
|
||||
return WebFetchResponse(
|
||||
message=f"Fetched {url}" + (" (truncated)" if truncated else ""),
|
||||
message=f"Fetched {url}",
|
||||
url=response.url,
|
||||
status_code=response.status,
|
||||
content_type=content_type.split(";")[0].strip(),
|
||||
content=text,
|
||||
truncated=truncated,
|
||||
truncated=False,
|
||||
session_id=session_id,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user