_process_large_message Hardcoded Path Fails with Non-Virtual Backends #171

Open
opened 2026-02-16 08:20:10 -05:00 by yindo · 1 comment
Owner

Originally created by @RuiFG on GitHub (Nov 20, 2025).

Originally assigned to: @eyurtsev on GitHub.

For middleware/filesystem.py we should not use root path-based f"/large_tool_results/{sanitized_id}"

  1. Permission Denied: When the backend is not in virtual mode (e.g., FilesystemBackend with virtual_mode=False), it attempts to write to the system root directory, which commonly fails due to insufficient permissions
  2. Eviction Failure: Due to silent error handling, the large content eviction mechanism fails completely, causing the tool message to remain oversized
    def _process_large_message(
        self,
        message: ToolMessage,
        resolved_backend: BackendProtocol,
    ) -> tuple[ToolMessage, dict[str, FileData] | None]:
        content = message.content
        if not isinstance(content, str) or len(content) <= 4 * self.tool_token_limit_before_evict:
            return message, None

        sanitized_id = sanitize_tool_call_id(message.tool_call_id)
        file_path = f"/large_tool_results/{sanitized_id}"
        result = resolved_backend.write(file_path, content)
        if result.error:
            return message, None
        content_sample = format_content_with_line_numbers([line[:1000] for line in content.splitlines()[:10]], start_line=1)
        processed_message = ToolMessage(
            TOO_LARGE_TOOL_MSG.format(
                tool_call_id=message.tool_call_id,
                file_path=file_path,
                content_sample=content_sample,
            ),
            tool_call_id=message.tool_call_id,
        )
        return processed_message, result.files_update
Originally created by @RuiFG on GitHub (Nov 20, 2025). Originally assigned to: @eyurtsev on GitHub. For `middleware/filesystem.py` we should not use root path-based `f"/large_tool_results/{sanitized_id}"` 1. Permission Denied: When the backend is not in virtual mode (e.g., FilesystemBackend with virtual_mode=False), it attempts to write to the system root directory, which commonly fails due to insufficient permissions 2. Eviction Failure: Due to silent error handling, the large content eviction mechanism fails completely, causing the tool message to remain oversized ```python def _process_large_message( self, message: ToolMessage, resolved_backend: BackendProtocol, ) -> tuple[ToolMessage, dict[str, FileData] | None]: content = message.content if not isinstance(content, str) or len(content) <= 4 * self.tool_token_limit_before_evict: return message, None sanitized_id = sanitize_tool_call_id(message.tool_call_id) file_path = f"/large_tool_results/{sanitized_id}" result = resolved_backend.write(file_path, content) if result.error: return message, None content_sample = format_content_with_line_numbers([line[:1000] for line in content.splitlines()[:10]], start_line=1) processed_message = ToolMessage( TOO_LARGE_TOOL_MSG.format( tool_call_id=message.tool_call_id, file_path=file_path, content_sample=content_sample, ), tool_call_id=message.tool_call_id, ) return processed_message, result.files_update ```
yindo added the bugdeepagentsexternalbackends labels 2026-02-16 08:20:10 -05:00
Author
Owner

@eyurtsev commented on GitHub (Nov 20, 2025):

Thanks for reporting!

@eyurtsev commented on GitHub (Nov 20, 2025): Thanks for reporting!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagents#171