Phase 01-model-interface: Foundation systems - 3 plan(s) in 2 wave(s) - 2 parallel, 1 sequential - Ready for execution
4.8 KiB
phase, plan, type, wave, depends_on, files_modified, autonomous, must_haves
| phase | plan | type | wave | depends_on | files_modified | autonomous | must_haves | |||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 01-model-interface | 02 | execute | 1 |
|
true |
|
Purpose: Create the foundation for managing conversation history, context windows, and memory compression before model switching logic is added. Output: Working context manager with message storage, compression, and token budget management.
<execution_context>
@/.opencode/get-shit-done/workflows/execute-plan.md
@/.opencode/get-shit-done/templates/summary.md
</execution_context>
Key classes:
- Message: role, content, timestamp, token_count, importance_score
- Conversation: messages list, metadata, total_tokens
- ContextBudget: max_tokens, used_tokens, available_tokens
- MessageMetadata: source, context, priority flags
Use dataclasses or Pydantic BaseModel for type safety and validation. Include proper type hints throughout. python -c "from src.models.conversation import Message, Conversation; msg = Message(role='user', content='test'); print(msg.role)" Conversation data structures support message creation and management
Task 2: Implement context manager with compression src/models/context_manager.py Create ContextManager class following research patterns: 1. Implement sliding window context management 2. Add hybrid compression: summarize old messages, preserve recent ones 3. Trigger compression at 70% of context window (from CONTEXT.md) 4. Prioritize user instructions and explicit requests during compression 5. Implement semantic importance scoring for message retention 6. Support different model context sizes (adaptive based on model)Key methods:
- add_message(message): Add message to conversation, check compression need
- get_context_for_model(model_key): Return context within model's token limit
- compress_conversation(target_ratio): Apply hybrid compression strategy
- estimate_tokens(text): Estimate token count for text (approximate)
- get_conversation_summary(): Generate summary of compressed messages
Follow research anti-patterns: Don't ignore context window overflow, use proven compression algorithms. python -c "from src.models.context_manager import ContextManager; cm = ContextManager(); print(cm.add_message) and hasattr(cm, 'compress_conversation')" Context manager handles conversation history with intelligent compression
Verify conversation management: 1. Messages can be added and retrieved from conversation 2. Context compression triggers at correct thresholds 3. Important messages are preserved during compression 4. Token estimation works reasonably well 5. Context adapts to different model window sizes<success_criteria> Conversation context system operational:
- Message storage and retrieval works correctly
- Context window management prevents overflow
- Intelligent compression preserves important information
- System ready for integration with model switching </success_criteria>