fix: configurable terminal output truncation to prevent context window blowup#1695
Open
darksider4all wants to merge 1 commit into
Open
fix: configurable terminal output truncation to prevent context window blowup#1695darksider4all wants to merge 1 commit into
darksider4all wants to merge 1 commit into
Conversation
Root cause: fix_full_output() had hardcoded 1M char threshold (~250K tokens). A grep through minified JS produced 1MB output, exceeding LLM context limits. Changes: - Add max_output_chars config (default: 30000 chars ~ 7.5K tokens) - Patch fix_full_output() to read from plugin config - Add max_output_chars to _get_config() Also patched usr/plugins/tree_sitter (local, gitignored) with .gitignore awareness + default ignore dirs for build_index.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
fix_full_output()incode_execution_tool.pyhad a hardcoded truncation threshold of1,000,000characters (~1MB / ~250K tokens). A single large command output (e.g., recursive grep through minified JS) could fill the entire LLM context window, crashing the session.Root Cause
File:
plugins/_code_execution/tools/code_execution_tool.py, line 475:python
output = truncate_text_agent(agent=self.agent, output=output, threshold=1000000)
Fix
Made the threshold configurable via plugin settings with a sensible default of 30,000 characters (~7.5K tokens):
Changes
default_config.yaml— Added config option:yaml
max_output_chars: 30000
code_execution_tool.py—fix_full_output()reads from config:python
cfg = _get_config(self.agent)
max_chars = cfg.get("max_output_chars", 30000)
output = truncate_text_agent(agent=self.agent, output=output, threshold=max_chars)
_get_config()— Added key:python
"max_output_chars": int(cfg.get("max_output_chars", 30000)),
Impact
Backwards Compatibility
Fully backwards compatible — agents/projects that need more output can set
max_output_charsto a higher value in their plugin config.