-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(sessions): Efficient Large Context Handling for Agent Development Kit #1247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Adewale-1
wants to merge
18
commits into
google:main
Choose a base branch
from
Adewale-1:context-reference-store
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5,263
−71
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… Store report - Add test_context_store_rouge_evaluation.py with 16 comprehensive ROUGE tests - Add test_context_store_agent_rouge_evaluation.py for integration testing - Update CONTEXT_REFERENCE_STORE_REPORT.md with correct ROUGE findings - Validate that Context Reference Store maintains identical quality (0.767 F-measure) - Document complete test suite: 34+ tests covering functionality and quality - Confirm zero quality degradation with 49x memory reduction and 625x serialization speedup
…1/adk-python into context-reference-store
- Add sophisticated eviction policies (LRU, LFU, TTL, Memory Pressure) - Implement priority-based context management with intelligent eviction - Add cache warming and access pattern tracking for hotspot optimization - Create background TTL cleanup with configurable intervals - Enhance metadata with frequency scoring and expiration tracking - Add comprehensive cache statistics and monitoring capabilities - Implement memory pressure monitoring with automatic resource management - Add psutil dependency for system memory monitoring - Create extensive test suite with 34 additional tests covering all advanced features - Validate performance improvements of 10-16% over baseline in many scenarios - Maintain backward compatibility with existing ADK interfaces - Update documentation with advanced caching implementation details
…odal functionality - Add multimodal storage architecture with hybrid binary storage - Include performance metrics showing 65,000x JSON overhead reduction - Document 99.55% storage reduction through binary deduplication - Add real-world examples and API usage for multimodal content - Update test coverage to include 12 multimodal-specific tests - Expand use cases to include computer vision and media-rich workflows - Enhance implementation details with binary storage methods - Update achievements with multimodal performance improvements
We are working on this in this work stream: #1085 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1246
Problem
With Gemini's introduction of massive context windows (1M tokens), existing approaches to context management in ADK have become inefficient:
Solution
This PR introduces a reference-based approach to context management with advanced caching strategies and comprehensive multimodal support:
Core Components
State
class with reference-based context handlingAdvanced Caching Strategies
Multimodal Storage Architecture
Performance Improvements
Comprehensive benchmarking shows dramatic improvements:
Original Context Reference Store Performance
Multimodal Performance Gains
The multimodal implementation delivers exceptional efficiency improvements:
Advanced Caching Performance Improvements
Enhanced versions often outperform baseline:
Performance Overhead Analysis:
Response Quality Validation (ROUGE Analysis)
Critical Finding: Comprehensive ROUGE testing validates that the Context Reference Store maintains identical response quality to the traditional ADK approach.
Baseline Comparison Results:
This validates that our 49x memory reduction, 625x serialization speedup, 99.55% multimodal storage reduction, and advanced caching features come with zero quality degradation.
Changes
Core Implementation
context_reference_store.py
withContextReferenceStore
andContextMetadata
classeslarge_context_state.py
withLargeContextState
classMultimodal Support
store_multimodal_content
,retrieve_multimodal_content
)types.Content
andtypes.Part
handlingAdvanced Caching Features
Documentation and Testing
Comprehensive Test Suite
Enhanced Test Coverage:
test_large_context_state.py
)test_multimodal_context_reference_store.py
)test_context_store_rouge_evaluation.py
)test_advanced_caching_strategies.py
)test_context_store_agent_rouge_evaluation.py
)Multimodal Test Coverage:
Advanced Caching Test Coverage:
Key Validation Points:
How to Run Tests
Key Achievements
Compatibility
This implementation is fully backward compatible with existing ADK code:
Documentation
Full documentation is provided in:
CONTEXT_REFERENCE_STORE_REPORT.md
Usage Examples
Basic Usage
Multimodal Content Usage
Advanced Caching Configuration
Multi-Agent Context Sharing with Multimodal Content
Real-World Impact
This implementation enables several previously impractical use cases:
Future Work
With advanced caching strategies and multimodal support now implemented, potential future enhancements include:
Checklist