Rules for optimizing context window usage across DeepSeek models including chunking strategies, summarization, and conversation management.
## DeepSeek Context Window Management
### Model Context Limits
- DeepSeek V3: 128K tokens context window
- DeepSeek R1: 128K tokens input, but optimal performance at <32K
- Claude Coder V2: 128K tokens
- Rule of thumb: performance degrades in the middle of long contexts ("lost in the middle" effect)
### Chunking Strategy
For documents exceeding comfortable context:
1. Split into semantic chunks (by section/paragraph, not by token count)
2. Maintain overlap between chunks (10-15% overlap)
3. Process each chunk independently
4. Aggregate results with a final summarization pass
### Conversation Management
- Track token count per conversation turn
- When approaching 80% of context limit, summarize earlier messages
- Keep system prompt + last 3-5 turns in full fidelity
- Archive older turns as compressed summaries
- Alert users when context is being truncated
### Priority Ordering
Place information in this order (most important first):
1. System instructions (if using V3)
2. Critical context (schemas, constraints, rules)
3. Current task description
4. Supporting examples or data
5. Conversation history (most recent first)
### Optimization Techniques
- Remove redundant whitespace and formatting in prompts
- Use abbreviations for repeated terms (define once, abbreviate after)
- Send structured data as compact JSON rather than prose
- For code: send only relevant functions, not entire files
- Use references: "Apply the same pattern as described above" instead of repeating
### Anti-Patterns
- Do not stuff the entire codebase into context
- Do not repeat instructions in every message
- Do not include irrelevant conversation history
- Do not use verbose XML tags when simpler markdown worksWorkflows from the Neura Market marketplace related to this DeepSeek resource