diff --git a/autogpt_platform/backend/backend/api/features/chat/sdk/service.py b/autogpt_platform/backend/backend/api/features/chat/sdk/service.py index 112aca4ab8..5d3c6c494f 100644 --- a/autogpt_platform/backend/backend/api/features/chat/sdk/service.py +++ b/autogpt_platform/backend/backend/api/features/chat/sdk/service.py @@ -1,8 +1,10 @@ """Claude Agent SDK service layer for CoPilot chat completions.""" import asyncio +import glob import json import logging +import os import uuid from collections.abc import AsyncGenerator from typing import Any @@ -54,9 +56,6 @@ _SDK_TOOL_RESULTS_GLOB = "/root/.claude/projects/*/tool-results/*" def _cleanup_sdk_tool_results() -> None: """Remove SDK tool-result files to prevent disk accumulation.""" - import glob - import os - for path in glob.glob(_SDK_TOOL_RESULTS_GLOB): try: os.remove(path) diff --git a/autogpt_platform/backend/backend/api/features/chat/sdk/tool_adapter.py b/autogpt_platform/backend/backend/api/features/chat/sdk/tool_adapter.py index ab2a56adef..45aa11c088 100644 --- a/autogpt_platform/backend/backend/api/features/chat/sdk/tool_adapter.py +++ b/autogpt_platform/backend/backend/api/features/chat/sdk/tool_adapter.py @@ -17,10 +17,6 @@ from backend.api.features.chat.tools.base import BaseTool logger = logging.getLogger(__name__) -# Safety-net truncation for extreme tool results (e.g. infinite loops). -# Normal oversized results are handled by the SDK via the Read tool. -MAX_TOOL_RESULT_CHARS = 500_000 - # Allowed base directory for the Read tool (SDK saves oversized tool results here) _SDK_TOOL_RESULTS_DIR = "/root/.claude/" @@ -107,18 +103,6 @@ def create_tool_handler(base_tool: BaseTool): else json.dumps(result.output) ) - # Safety-net truncation for extreme results (e.g. infinite loops). - # Normal oversized results are handled by the SDK + our Read tool. - if len(text) > MAX_TOOL_RESULT_CHARS: - logger.warning( - f"Tool {base_tool.name} result truncated: " - f"{len(text)} -> {MAX_TOOL_RESULT_CHARS} chars" - ) - text = ( - text[:MAX_TOOL_RESULT_CHARS] - + f"\n\n... [truncated — {len(text) - MAX_TOOL_RESULT_CHARS} chars omitted]" - ) - return { "content": [{"type": "text", "text": text}], "isError": not result.success,