Skip to content

fix(sandbox): 对齐 Manus——读文件不默认硬截断 - #207

Merged
Simpleyyt merged 3 commits into
mainfrom
cursor/fix-sandbox-truncation-b72a
Aug 13, 2026
Merged

fix(sandbox): 对齐 Manus——读文件不默认硬截断#207
Simpleyyt merged 3 commits into
mainfrom
cursor/fix-sandbox-truncation-b72a

Conversation

@Simpleyyt

@Simpleyyt Simpleyyt commented Aug 13, 2026

Copy link
Copy Markdown
Owner

对齐官方 Manus

官方 Manus 的 file_read 没有 max_length,靠工具说明引导模型:

  • 不确定时先读前 20 行
  • 大文件用 start_line / end_line
  • 注意大文件性能

进模型的上下文体积由上层预算控制,而不是 sandbox API 硬砍。

改动

行为
sandbox file/read 默认不截断max_length 仅作可选硬上限
str_replace / find_in_content 始终读全文件(避免大文件写坏)
Computer / Diff / file_view 完整内容
FileToolkit 说明 对齐 Manus:先读 20 行、注意大文件
backend max_tool_result_chars 16k 裁剪进 LLM 的 tool result,并提示按行重读

测试

cd sandbox && PYTHONPATH=. python3 -m pytest tests/test_file_truncation.py -v --asyncio-mode=auto
# 5 passed
Open in Web Open in Cursor 

cursoragent and others added 2 commits August 13, 2026 15:32
The file/read API defaulted to max_length=10000, which cut Computer panel
file views, diffs, and agent file_read results with a "(truncated)" suffix.
Worse, str_replace and find_in_content reused that truncated read, so
replacing in files larger than 10KB could wipe the tail of the file.

Default max_length to None (full content); keep optional truncation when
callers pass an explicit limit. Always read the full file for replace/search.

Co-authored-by: Simpleyyt <simpleyyt@gmail.com>
Restore the default 10k cap on file/read so agents cannot dump huge files
into context, with a clearer truncation hint to use start_line/end_line.
str_replace / find_in_content still read the full file to avoid corruption.
Computer panel / file_view request max_length=null for untruncated display.

Co-authored-by: Simpleyyt <simpleyyt@gmail.com>
@cursor cursor Bot changed the title fix(sandbox): 取消 file/read 默认截断,避免大文件被砍断/写坏 fix(sandbox): 模型读文件仍限 10k,UI/替换读全量 Aug 13, 2026
Match official Manus: file/read has no default max_length; agents are
guided to use start_line/end_line (start with first 20 lines when unsure).
Context size is bounded by backend max_tool_result_chars (16k), not the
sandbox API. Keep optional max_length for explicit caps; replace/search
and UI still read full files.

Co-authored-by: Simpleyyt <simpleyyt@gmail.com>
@cursor cursor Bot changed the title fix(sandbox): 模型读文件仍限 10k,UI/替换读全量 fix(sandbox): 对齐 Manus——读文件不默认硬截断 Aug 13, 2026
@Simpleyyt
Simpleyyt marked this pull request as ready for review August 13, 2026 17:33
@Simpleyyt
Simpleyyt merged commit 5965913 into main Aug 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants