Conversation
Summary of ChangesHello @jayy-77, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the event compaction mechanism by introducing configurable thresholds for token count and recent event retention. These additions provide more control over when and how events are summarized, improving the efficiency and relevance of context management within LLM-backed applications. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Response from ADK Triaging Agent Hello @jayy-77, thank you for creating this PR! Could you please fill out the PR template in the description? This includes linking to the issue this PR is addressing and providing a testing plan. This information will help reviewers to review your PR more efficiently. Thanks! |
There was a problem hiding this comment.
Code Review
This pull request introduces new context compaction features, specifically token_threshold and retain_recent_events, to better manage conversation context in LLM-backed applications. The changes include adding these configuration options to EventsCompactionConfig, updating the maybe_summarize_events function to utilize them, and adding a new integration test. The overall structure and intent of the changes are clear and address a common challenge in LLM applications.
| def count_tokens(events: list[Event]) -> int: | ||
| return sum(len(event.content.parts) for event in events if event.content) |
There was a problem hiding this comment.
The count_tokens function is currently a placeholder that sums the number of parts in an event's content. This is a very rough approximation and does not accurately reflect the actual token count that an LLM would use. For the token_threshold feature to be effective and reliable, this logic needs to be replaced with a proper tokenization mechanism, ideally one that is specific to the LLM being used or a widely accepted tokenizer (e.g., tiktoken). An inaccurate token count could lead to either premature compaction or exceeding the LLM's context window, impacting performance and context retention.
| def count_tokens(events: list[Event]) -> int: | |
| return sum(len(event.content.parts) for event in events if event.content) | |
| def count_tokens(events: list[Event]) -> int: | |
| # TODO(developer): Replace this placeholder with actual LLM-specific token counting logic. | |
| # For example, using a tokenizer from the LLM or a library like tiktoken. | |
| return sum(len(event.content.parts) for event in events if event.content) |
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
#4146
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
If applicable, please follow the issue templates to provide as much detail as
possible.
Problem:
A clear and concise description of what the problem is.
Solution:
A clear and concise description of what you want to happen and why you choose
this solution.
Testing Plan
Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes.
Unit Tests:
Please include a summary of passed
pytestresults.Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix.
Checklist
Additional context
Add any other context or screenshots about the feature request here.