GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(opencode): switch tool truncation to token-based limits by Skyline-23 · Pull Request #9648 · anomalyco/opencode

Conversation

@Skyline-23

@Skyline-23 Skyline-23 commented Jan 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Summary

  • switch global tool output truncation from byte limits to token budgets
  • update Read tool truncation messaging to token-based limits
  • align bash tool help text and truncation tests with token limits

Testing

  • bun test test/tool/truncation.test.ts
  • bun test test/tool/bash.test.ts

References

  • Fixes Codex model response latency increases significantly as conversation grows #9045

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot AI review requested due to automatic review settings January 20, 2026 16:13
@github-actions github-actions Bot added the needs:title label Jan 20, 2026
@github-actions

github-actions Bot commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

Hey! Your PR title Switch tool truncation to token-based limits doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot started reviewing on behalf of Skyline-23 January 20, 2026 16:13
View session
@github-actions

github-actions Bot commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

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

Based on my search results, I found some related PRs that deal with output limits and truncation, but none appear to be direct duplicates of PR #9648. Here are the potentially related PRs:

Related PRs (not duplicates):

  1. PR feat(opencode): add context overflow prevention with configurable thresholds #8810 - feat(opencode): add context overflow prevention with configurable thresholds

    • Related to managing tool output and context limits, but appears to be about overflow prevention rather than token-based truncation
  2. PR fix(grep): stream ripgrep output to prevent memory exhaustion #5432 - fix(grep): stream ripgrep output to prevent memory exhaustion

    • Related to managing tool output size, but focused on grep/ripgrep specifically
  3. PR feat: add file persistence for large tool outputs #6234 - feat: add file persistence for large tool outputs

    • Related to handling large tool outputs, but uses file persistence approach rather than token-based limits

These PRs address related concerns about tool output management, but none appear to be duplicate work on the same token-based truncation feature that PR #9648 implements.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot AI reviewed Jan 20, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Pull request overview

This pull request switches the tool output truncation system from byte-based limits to token-based limits for more accurate context management. The token estimation uses a simple 4 characters per token approximation.

Changes:

  • Replaced MAX_BYTES (50KB) with MAX_TOKENS (10,000) as the default truncation limit
  • Updated truncation logic to use Token.estimate() instead of Buffer.byteLength()
  • Updated user-facing messages in Read and Bash tools to reference tokens instead of bytes

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/opencode/src/tool/truncation.ts Core implementation: renamed constants, options, and variables from byte-based to token-based; replaced byte counting with token estimation
packages/opencode/src/tool/read.ts Updated Read tool to use token-based truncation and updated user-facing messages to reference tokens
packages/opencode/src/tool/bash.ts Updated template variable replacement from maxBytes to maxTokens
packages/opencode/src/tool/bash.txt Updated help text to reference token limits instead of byte limits
packages/opencode/test/tool/truncation.test.ts Updated test descriptions and assertions to use token-based expectations; added Token import
packages/opencode/test/tool/bash.test.ts Updated truncation test to generate token-based test data

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Skyline-23 Skyline-23 changed the title Switch tool truncation to token-based limits feat(opencode): switch tool truncation to token-based limits Jan 20, 2026
@github-actions github-actions Bot removed the needs:title label Jan 20, 2026
@Skyline-23

Skyline-23 commented Jan 20, 2026

Copy link
Copy Markdown
Author

Updated the PR title to conventional format and added Fixes #9045 in the description.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Skyline-23
Skyline-23 force-pushed the perf/token-truncation branch from d11838e to 6dd40a4 Compare January 21, 2026 03:05
Skyline-23 added 2 commits January 23, 2026 18:58
@Skyline-23
switch tool truncation to token-based limits
b376427
@Skyline-23
update bash truncation test for token limits
ea7d600
@Skyline-23
Skyline-23 force-pushed the perf/token-truncation branch from 6dd40a4 to ea7d600 Compare January 23, 2026 10:01
@thdxr
thdxr force-pushed the dev branch from cbab81f to 2d3c7a0 Compare January 30, 2026 04:49
@opencode-agent
opencode-agent Bot force-pushed the dev branch from 00637c0 to 71e0ba2 Compare January 30, 2026 14:32
@thdxr
thdxr force-pushed the dev branch 3 times, most recently from f1ae801 to 08fa7f7 Compare January 30, 2026 14:37
@github-actions github-actions Bot mentioned this pull request Feb 11, 2026
docs(tools): document automatic tool output truncation #13119
Closed
@github-actions

github-actions Bot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this Mar 25, 2026
@YanzheL YanzheL mentioned this pull request Apr 12, 2026
fix: reuse OpenAI Responses previous_response_id across turns #22149
Closed
3 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Codex model response latency increases significantly as conversation grows

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Skyline-23
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.