Skip to content

fix(tools): stop right-padding tool result lines sent to the model - #1593

Merged
edenreich merged 1 commit into
mainfrom
fix/issue-1590
Oct 20, 2026
Merged

edenreich merged 1 commit into
mainfrom
fix/issue-1590

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

Resolves #1590

Summary

Tool results reach the model through the expanded lipgloss tree, and lipgloss.JoinHorizontal pads every line of a multi-line node to the node's widest line. A Read of a file with one 120-char line sent every line of that file as 124 runes. On the run in #1586, 58 tool results with 296k chars of content left the CLI as 1.33M chars on every request, which is also why the chars/4 compaction estimate ran 2x above the provider's prompt_tokens.

Changes

  • renderExpandedTree passes its output through trimLinePadding, which drops the trailing spaces per line. One choke point covers every tool's FormatExpanded.
  • TestFormatExpandedKeepsLineLengths pins that no line of a rendered result ends in padding and the short line keeps its own length.

no docs ticket: internal bug fix, no user-facing behavior change beyond smaller requests.

lipgloss pads every line of a multi-line tree node to the node's widest
line, so a Read of a file with one long line reached the model with
every line stretched to that width. On the run in #1586 that turned
296k chars of tool output into 1.33M chars, every request. The expanded
tree now trims the trailing spaces lipgloss adds, which keeps the
compaction estimate near the provider's prompt_tokens and stops sending
the padding.
@edenreich
edenreich requested a review from a team as a code owner October 20, 2026 20:33
@github-project-automation github-project-automation Bot moved this to Todo in 2026 Oct 20, 2026
@edenreich edenreich moved this from Todo to QA in 2026 Oct 20, 2026
@edenreich
edenreich merged commit 15a7470 into main Oct 20, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-1590 branch October 20, 2026 20:47
@edenreich edenreich moved this from QA to Done in 2026 Oct 20, 2026
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.234.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] Tool results sent to the LLM are right-padded to the widest line

1 participant