Skip to content

fix(opencode): respect configured read truncation limits for read tool#29896

Draft
wellescastro wants to merge 1 commit into
anomalyco:devfrom
wellescastro:add-truncate-service-to-read-tool
Draft

fix(opencode): respect configured read truncation limits for read tool#29896
wellescastro wants to merge 1 commit into
anomalyco:devfrom
wellescastro:add-truncate-service-to-read-tool

Conversation

@wellescastro
Copy link
Copy Markdown

@wellescastro wellescastro commented May 29, 2026

Issue for this PR

Closes #29604 #25337

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The read tool was still using hard-coded truncation defaults in places instead of the configured tool_output limits. It also handled directory listings separately from the generic truncation wrapper, so directory reads could respect the line limit while ignoring the byte limit. This PR makes read use Truncate.Service.limits() for its default line and byte caps. File reads now use the configured byte limit, and directory reads apply both the configured line limit and byte limit before returning output. The truncation message now reflects the configured byte cap instead of a hard-coded value.

How did you verify your code works?

Created new and run the existing read tool tests locally:

cd packages/opencode
bun test --timeout 30000 test/tool/read.test.ts

Result:

42 pass
0 fail
98 expect() calls

Screenshots / recordings

Not applicable, no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential related PRs found:

  1. PR feat(core): allow disabling tool output truncation #28907 - feat(core): allow disabling tool output truncation

Note: PR #29896 (the current PR) appears in all searches, which is expected. The other results are unrelated.

The main related PR is #28907, which deals with tool output truncation configuration—the feature that PR #29896 is now making the read tool properly respect.

@wellescastro wellescastro changed the title fix(opencode): respect configured read truncation limits fix(opencode): respect configured read truncation limits for read tool May 29, 2026
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.

Should the Read tool respect opencode config values for max_bytes and max_lines?

1 participant