Skip to content

Conversation

@yurekami
Copy link

Summary

Implements a context window limit notification system to improve user experience during long conversations. This directly addresses issue #1050.

Features Added:

  • ContextTracker utility class (inference/context_tracker.py):

    • Real-time token count tracking
    • Visual progress bar with color-coded status (green → yellow → red)
    • Warning notifications at 75% and 90% thresholds
    • Estimates for remaining tokens and conversation turns
  • New interactive commands:

    • /context - Display current context window usage
    • /summary - Get a prompt to summarize the conversation
    • Enhanced /clear with confirmation message
  • Automatic notifications:

    • Progress bar displayed after each response
    • Warnings when approaching context limits
    • Suggestions for summarization to preserve important context

Example Output

📊 Context window: 16,384 tokens
💡 Commands: /exit (quit), /clear (new chat), /context (show usage), /summary (get summary prompt)

>>> Hello!

[Response...]

[██████████░░░░░░░░░░░░░░░░░░░░] Context: 1,234/16,384 (7.5%)

At 75% capacity:

⚠️  Context window at 75% capacity.
💡 Tip: Consider summarizing key points to preserve important context.

Test plan

  • Verify syntax with python -m py_compile inference/context_tracker.py inference/generate.py
  • Test interactive mode shows context usage after each response
  • Test /context command displays usage stats
  • Test /summary command shows summarization prompt
  • Test /clear resets the context tracker
  • Verify warnings appear at 75% and 90% thresholds

Closes #1050

🤖 Generated with Claude Code

Implements a ContextTracker utility that provides:
- Real-time token count tracking during conversations
- Visual progress bar showing context window usage
- Warning notifications at 75% and 90% thresholds
- New commands: /context, /summary for user control
- Summarization suggestions when approaching capacity

This improves user experience by providing transparency about
context limits and helping users manage long conversations.

Closes deepseek-ai#1050

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

Context window limit notification system

1 participant