Skip to content

Conversation

@Faizanq
Copy link

@Faizanq Faizanq commented Dec 28, 2025

Fixes #833

The truncation threshold was hardcoded at 1MB which causes ContextWindowExceededError on smaller context windows.

Changed to calculate threshold based on model's context settings (12.5% of available history, min 50K chars). This matches the pattern already used in history.py for large messages.

…#833)

Prevent ContextWindowExceededError when single command output exceeds
context limit. Previously hardcoded at 1MB which could overflow smaller
context windows.

Now calculates threshold based on model's context window settings,
matching the LARGE_MESSAGE_TO_TOPIC_RATIO pattern used in history.py.
@frdel
Copy link
Collaborator

frdel commented Dec 30, 2025

This truncation is not intended for the LLM, that is meant to truncate the tool output before saving it to a file, which happens automatically in _90_save_tool_call_file.py.
For LLM, all messages should be truncated automatically in history.py, if that does not happen, then the bug is there. I'll do some tests.

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.

2 participants