Skip to content

Conversation

continue[bot]
Copy link
Contributor

@continue continue bot commented Oct 7, 2025

Summary

This PR addresses CON-4274 by adding two improvements to handle large context in the CLI:

  1. Pruning fallback: When context length validation fails before sending chat messages, we now use the existing compileChatMessages pruning logic from core/llm/countTokens.js as a fallback. This removes older messages while preserving the system message, tools, and the most recent user/tool sequence.

  2. Bash tool output truncation: The Bash tool now truncates output by both:

    • Lines: 5000 lines (existing)
    • Characters: 200,000 characters (new)

    Whichever limit is hit first will trigger truncation with an appropriate message.

Changes

  • extensions/cli/src/stream/streamChatResponse.ts: Added pruning fallback in processStreamingResponse when context validation fails
  • extensions/cli/src/tools/runTerminalCommand.ts: Added character-based truncation to Bash tool output

Testing

  • The pruning logic reuses the well-tested compileChatMessages function from core
  • Character truncation follows the same pattern as the existing line truncation

Fixes CON-4274


This agent session was co-authored by nate and Continue.


Summary by cubic

Prevents oversized contexts from breaking CLI requests by pruning chat history and truncating Bash tool output. Fixes CON-4274 and improves reliability with large conversations and long command results.

  • New Features
    • Prunes chat history when context-length validation fails using compileChatMessages; preserves system, tools, and the latest exchange.
    • Truncates Bash tool output to 5000 lines or 200,000 characters (whichever comes first) and adds a clear truncation notice.

- Add compileChatMessages pruning as fallback when context length validation fails
- Truncate Bash tool output by both lines (5000) and characters (200000)
- Reuse existing pruning logic from core/llm/countTokens.js
- Log pruning details when it occurs

Fixes CON-4274

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <[email protected]>
Co-authored-by: nate <[email protected]>
@chezsmithy
Copy link
Contributor

I'd recommend a different truncation strategy for the bash output. Perhaps keep the last X lines from the end backwards to capture the outcome of tests and installs.

@TyDunn TyDunn marked this pull request as ready for review October 16, 2025 18:45
@TyDunn TyDunn requested a review from a team as a code owner October 16, 2025 18:45
@TyDunn TyDunn requested review from RomneyDa and removed request for a team October 16, 2025 18:45
Copy link

⚠️ PR Title Format

Your PR title doesn't follow the conventional commit format, but this won't block your PR from being merged. We recommend using this format for better project organization.

Expected Format:

<type>[optional scope]: <description>

Examples:

  • feat: add changelog generation support
  • fix: resolve login redirect issue
  • docs: update README with new instructions
  • chore: update dependencies

Valid Types:

feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert

This helps with:

  • 📝 Automatic changelog generation
  • 🚀 Automated semantic versioning
  • 📊 Better project history tracking

This is a non-blocking warning - your PR can still be merged without fixing this.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 16, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

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

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants