Skip to content

feat: write truncated tool outputs to files#7239

Merged
rekram1-node merged 14 commits intodevfrom
truncate-to-file
Jan 7, 2026
Merged

feat: write truncated tool outputs to files#7239
rekram1-node merged 14 commits intodevfrom
truncate-to-file

Conversation

@rekram1-node
Copy link
Copy Markdown
Collaborator

@rekram1-node rekram1-node commented Jan 7, 2026

closes: #7168
closes: #4560

Combines ideas from:
#6234 by @ben-vargas
#6048 by @shantur

@rekram1-node rekram1-node marked this pull request as draft January 7, 2026 18:16
@rekram1-node
Copy link
Copy Markdown
Collaborator Author

/review

Comment thread packages/opencode/src/tool/truncation.ts Outdated
Comment thread packages/opencode/src/tool/truncation.ts Outdated
@rekram1-node
Copy link
Copy Markdown
Collaborator Author

/review

Comment thread packages/opencode/src/tool/truncation.ts
@rekram1-node
Copy link
Copy Markdown
Collaborator Author

/review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 7, 2026

lgtm

@rekram1-node rekram1-node marked this pull request as ready for review January 7, 2026 22:28
@rekram1-node
Copy link
Copy Markdown
Collaborator Author

/review

Comment thread packages/opencode/src/tool/read.ts
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 7, 2026

Overall the PR looks good! The main suggestion is a minor style preference:

  • The else if/else chain in read.ts (line 130-134) could potentially use early returns, but the current code is readable and this is not a violation per se.

The code follows good practices, uses Bun APIs appropriately, and the implementation is solid. The let statements used are appropriate for loop contexts.

@rekram1-node
Copy link
Copy Markdown
Collaborator Author

/review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 7, 2026

lgtm

@rekram1-node rekram1-node merged commit 1b82511 into dev Jan 7, 2026
3 checks passed
triklozoid pushed a commit to triklozoid/opencode that referenced this pull request Feb 2, 2026
xywsxp pushed a commit to xywsxp/opencode that referenced this pull request Apr 24, 2026
@jogoossens
Copy link
Copy Markdown

This seem to have adverse effects, only 50kb of agents.MD files is read :/

@rekram1-node
Copy link
Copy Markdown
Collaborator Author

agents.md files are parsed independent of this

@rekram1-node
Copy link
Copy Markdown
Collaborator Author

also this changed 0 about reading of files

@jogoossens
Copy link
Copy Markdown

jogoossens commented May 5, 2026

The cap is OpenCode‑side, not model‑side:

The stored tool result is 53,592 chars and ends with: (Output capped at 50 KB. Showing lines 1-526. Use offset=527 to continue.)
Where: packages/opencode/src/tool/read.ts line 18, MAX_BYTES = 50 * 1024. This runs in the OpenCode process, before tool output ever reaches the LLM. It applies identically whether the agent is talking to Qwen 3.5, Qwen 3.6, gpt‑5.4, or anything else.
First introduced: upstream commit 1b82511 on 2026‑01‑07 (PR #7239).
First tagged release containing it: v1.2.0, published 2026‑02‑14.

It is not /AGENTS.md, that one does read 100% ,it are subfolders like apps/AGENTS.md that seem to have the cap.

We added some subfolder AGENTS.md to instructions and the used tokens are suddenly way higher. We also saw that rules on top of apps/AGENTS.md were used by the model, rules on the bottom were completely ignored.

I would say at least something is going on ,manually apps/agents.MD to instructions made the file be read 100%

Rwanbt pushed a commit to Rwanbt/opencode that referenced this pull request May 5, 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.

[Feature] Add Fetch tool that saves to file (like Claude Code) [FEATURE]: Context protection for tool calls when response is large

2 participants