Skip to content

tool/workspaceexec: add workspace-scoped file tools sharing workspace_exec state#1683

Draft
bytethm wants to merge 1 commit into
trpc-group:mainfrom
bytethm:workspaceexec-file-tools
Draft

tool/workspaceexec: add workspace-scoped file tools sharing workspace_exec state#1683
bytethm wants to merge 1 commit into
trpc-group:mainfrom
bytethm:workspaceexec-file-tools

Conversation

@bytethm
Copy link
Copy Markdown
Contributor

@bytethm bytethm commented Apr 23, 2026

Introduce six file tools (workspace_read_file, workspace_list_dir, workspace_search_file, workspace_search_content, workspace_write_file, workspace_replace_content) that operate on the same invocation-scoped workspace as workspace_exec. They reuse the WorkspaceRegistry, resolver, and reconcile layer added in #1660, and refuse to write framework-managed paths (work/inputs/, skills/, and WorkspaceBootstrapSpec.Files targets).

Expose them through an opt-in llmagent.WithWorkspaceFileToolsEnabled option. Extend WorkspaceExecRequestProcessor to compose exec and filetools guidance so both surfaces receive consistent instructions, including write-protection and truncation semantics.

…_exec state

Introduce six file tools (workspace_read_file, workspace_list_dir,
workspace_search_file, workspace_search_content, workspace_write_file,
workspace_replace_content) that operate on the same invocation-scoped
workspace as workspace_exec. They reuse the WorkspaceRegistry, resolver,
and reconcile layer added in trpc-group#1660, and refuse to write framework-managed
paths (work/inputs/**, skills/**, and WorkspaceBootstrapSpec.Files
targets).

Expose them through an opt-in llmagent.WithWorkspaceFileToolsEnabled
option. Extend WorkspaceExecRequestProcessor to compose exec and
filetools guidance so both surfaces receive consistent instructions,
including write-protection and truncation semantics.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 64f747bb-50ed-4fd1-a1c8-38770411c465

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 68.49530% with 402 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.33852%. Comparing base (4bfad3e) to head (fd864a0).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
tool/workspaceexec/file_backend.go 49.53488% 171 Missing and 46 partials ⚠️
tool/workspaceexec/file_tools.go 73.96280% 133 Missing and 49 partials ⚠️
agent/llmagent/surface_runtime.go 82.35294% 2 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (68.49530%) is below the target coverage (85.00000%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main       #1683         +/-   ##
===================================================
- Coverage   88.49296%   88.33852%   -0.15444%     
===================================================
  Files            860         862          +2     
  Lines         169896      171119       +1223     
===================================================
+ Hits          150346      151164        +818     
- Misses         14237       14543        +306     
- Partials        5313        5412         +99     
Flag Coverage Δ
unittests 88.33852% <68.49530%> (-0.15444%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

f := files[0]
content := []byte(f.Content)
if int64(len(content)) > maxBytes {
content = content[:maxBytes]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capping raw bytes here can split a UTF 8 rune, so a valid large text file starts failing workspace_read_file and workspace_search_content as not text. Please trim the capped buffer to the last complete rune before returning it.

中文 这里直接按字节截断会切开 UTF 8 rune,合法的大文本会让 `workspace_read_file` 和 `workspace_search_content` 被误报为非文本。请在返回前把截断结果回退到最后一个完整 rune 边界。

out.FilesSkipped++
continue
}
out.FilesScanned++
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max_files is described as an inspect cap, but skipped unreadable files do not increment FilesScanned here. A tree full of skipped files can bypass the limit and still return a later match with truncated=false, so please count inspected files before read and validation.

中文 `max_files` 这里定义的是检查上限,但跳过的不可读文件不会增加 `FilesScanned`。大量被跳过的文件会绕过这个限制,还可能在 `truncated=false` 时返回更后面的命中,所以请在读取和校验前就统计已检查文件数。

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