Skip to content

v2: generic tool output truncation drops the tail (skills, MCP results) #62718

Open

Description

@vvvzhangshuo

v2: generic tool output truncation drops the tail (skills, MCP results)

Description

When a tool result exceeds tool_output (default 2,000 lines / 50 KiB), ToolOutput.truncate keeps only the first lines. Everything after the cut never reaches the model.

Shell output already keeps the end: packages/core/src/shell.ts pages from size - maxBytes and reports the last line range. Other tools keep the start. That asymmetry is the problem:

  • a large SKILL.md whose final checklist or "do not" rules sit at the bottom
  • an MCP tool whose result field is at the end of a long pretty-printed response
  • a long build log where the error is in the last few lines

The marker does tell the model that the full output was saved to a file, but in practice it often continues without reading it.

This is the same shape as #54148 (closed as not_planned because it was reported on v1; the bot asked for a v2 report and a link back). Related: #35661 (MCP output truncated at 50 KB). Reproduces on current dev.

Steps to reproduce

  1. Configure tool_output: { "max_lines": 10 }.
  2. Call a tool or plugin that returns 100 numbered lines (or load a SKILL.md larger than 50 KiB).
  3. The model receives lines 1-10 plus the marker; lines 11-100 never reach it.

OpenCode version

0.0.0-dev (v2 dev @ da8c0211f7)

Operating System

Linux

Terminal

Konsole

Suggested direction

Keep both ends instead of only the head:

  • head and tail share max_lines
  • the marker keeps line ranges, e.g. [showing lines 1-5 and 96-100 of 100; ...], so it still matches read's offset
  • attachments keep their original relative position
  • the full output is still written to the retained file

If generic head+tail is unwanted, a narrower option is to keep the tail only for MCP/skill results, but the generic truncation path is where the loss happens.

Activity

  1. opencodejr commented on Nov 8, 2026

    @opencodejr
    Contributor

    Thanks for the detailed write-up, and for linking back to #54148!

    You're asking for generic tool-output truncation in v2 to keep both the start and the end of an oversized result, not just the start. That way the end of a large SKILL.md, an MCP response or a build log still reaches the model, and the marker still shows line ranges that match read's offset.

    Right now ToolOutput.truncate keeps the first lines on purpose. It saves the full output to a file and adds a marker pointing to it, so this is a change to how truncation is designed rather than a bug. It's a reasonable one, especially since shell output already keeps the end. I've marked it as a feature request for the maintainers to consider, along with your PR #62719.

    Related issues:

    I don't think a plugin can do this today, because I couldn't find a plugin hook that changes a tool's result before it is truncated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions