Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: coder/blink
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: coder/blink
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: feat/conversation-compaction
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 7 commits
  • 7 files changed
  • 2 contributors

Commits on Dec 16, 2025

  1. feat(scout-agent): add conversation compaction module

    Adds conversation compaction support to prevent context overflow errors.
    
    Features:
    - Token counting using ai-tokenizer with model-specific accuracy
    - Compaction tool (compact_conversation) for summarizing conversations
    - Warning message generation when approaching token limits
    - Context length error detection for various providers
    - Emergency compaction for when compaction request exceeds context
    
    Exports:
    - countConversationTokens - Count tokens in ModelMessage[]
    - shouldCompact - Check if compaction is needed
    - findCompactionSummary - Find existing compaction in messages
    - applyCompaction - Replace pre-compaction messages with summary
    - createCompactionTool - Create the compact_conversation tool
    - createCompactionWarningMessage - Generate warning message
    - isContextLengthError - Detect context overflow errors
    - calculateEmergencyCompactionConfig - Plan emergency compaction
    - createEmergencyCompactionMessage - Generate emergency request
    - prepareEmergencyCompactionMessages - Split messages for emergency
    
    Includes 21 tests covering all functionality.
    blink-so[bot] committed Dec 16, 2025
    Configuration menu
    Copy the full SHA
    1de5efa View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d062a49 View commit details
    Browse the repository at this point in the history
  3. feat(scout-agent): wire compaction logging into buildStreamTextParams

    This commit:
    - Imports applyCompaction and createCompactionTool from ./compaction
    - Applies compaction to messages before processing in buildStreamTextParams
    - Logs when compaction is applied (showing message count reduction)
    - Adds the compaction tool to the tools object so the model can call it
    - Uses compacted messages for Slack metadata detection and model conversion
    - Fixes isolated declarations issue in createCompactionTool by adding return type
    - Fixes test assertion for execute method on Tool type
    blink-so[bot] committed Dec 16, 2025
    Configuration menu
    Copy the full SHA
    f14c7cb View commit details
    Browse the repository at this point in the history
  4. feat(scout-agent): add automatic compaction when token threshold exce…

    …eded
    
    This commit adds:
    - New compaction option in BuildStreamTextParamsOptions to configure:
      - warningThreshold: token count that triggers compaction warning (default: 80% of max)
      - maxTokenThreshold: maximum tokens for context (default: 100k)
      - modelName: model name for token counting
      - Set to false to disable compaction features
    - Token counting using ai-tokenizer after message conversion
    - Automatic injection of compaction warning message when threshold exceeded
    - Logging for token thresholds and warning injection
    - Tests for:
      - Compaction tool is included by default
      - Existing compaction summaries are applied
      - Warning message is injected when threshold exceeded
      - Compaction can be disabled with compaction: false
      - Custom thresholds are respected
    
    Note: core.test.ts tests may not run locally due to bun/HTTPParser
    incompatibility, but work in CI.
    blink-so[bot] committed Dec 16, 2025
    Configuration menu
    Copy the full SHA
    3da054d View commit details
    Browse the repository at this point in the history
  5. refactor(scout-agent): remove maxTokenThreshold option

    maxTokenThreshold was only used for display in the warning message.
    Simplified to just use warningThreshold for both triggering and display.
    blink-so[bot] committed Dec 16, 2025
    Configuration menu
    Copy the full SHA
    9701d4d View commit details
    Browse the repository at this point in the history
  6. refactor(scout-agent): only include compaction tool when warning is i…

    …njected
    
    The compact_conversation tool is now only available when the token
    threshold is exceeded and the warning message is injected. This keeps
    the tool list clean when compaction is not needed.
    
    Updated tests to verify:
    - Tool is NOT available when under threshold
    - Tool IS available when warning is injected
    - Tool is NOT available when compaction is disabled
    blink-so[bot] committed Dec 16, 2025
    Configuration menu
    Copy the full SHA
    a53abda View commit details
    Browse the repository at this point in the history
  7. refactor

    hugodutka committed Dec 16, 2025
    Configuration menu
    Copy the full SHA
    c02246f View commit details
    Browse the repository at this point in the history
Loading