-
Notifications
You must be signed in to change notification settings - Fork 1
Context engineering - Introducing Summarization Node to React Agent #43
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
Conversation
… constants - Added new configuration constants for summarization: MAX_AGGREGATE_TOKENS_IN_SUMMARY_AND_OUTPUT, MAX_TOKENS_TO_TRIGGER_SUMMARY, and MAX_TOKENS_IN_SUMMARY_ONLY. - Updated the summarization prompt to include detailed analysis structure and ensure comprehensive coverage of user requests and intents. - Refactored the get_summarization_node function to utilize the new configuration constants for token limits. - Introduced unit tests for the summarization node to validate its functionality and configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @RheagalFire, 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 focuses on enhancing the React Agent's ability to handle long conversations by introducing a robust context engineering mechanism. I've implemented a summarization node that intelligently condenses chat history, ensuring the agent maintains relevant context without exceeding token limits. This change improves the agent's long-term conversational capabilities and overall efficiency.
Highlights
- New Summarization Node Introduction: I've introduced a new
SummarizationNodefrom thelangmemlibrary, specifically designed to manage and summarize conversation history within the React Agent. This node will help prevent context window overflow by condensing past interactions into a concise summary. - React Agent Integration: The
SummarizationNodeis integrated into thecreate_react_agentfunction as apre_model_hook. This means that before the agent's main model is invoked, the conversation history will be processed by the summarization node, ensuring the model always receives a manageable and relevant context. - Configurable Token Limits: New configuration variables have been added to
src/katalyst/app/config.pyto control the summarization behavior. These includeMAX_AGGREGATE_TOKENS_IN_SUMMARY_AND_OUTPUT,MAX_TOKENS_TO_TRIGGER_SUMMARY, andMAX_TOKENS_IN_SUMMARY_ONLY, allowing fine-grained control over when summarization occurs and its output size. - Detailed Summarization Prompt: A comprehensive
SUMMARIZATION_PROMPThas been defined, guiding the LLM to create structured summaries that capture key details such as user requests, technical concepts, code changes, problem-solving efforts, and pending tasks. This ensures the generated summaries are highly informative and actionable. - Dedicated LLM Configuration for Summarization: I've updated
src/katalyst/katalyst_core/config/llm_config.pyto include a specificsummarizerrole, mapping it to theexecutionmodel type. This allows for dedicated LLM models to be used for summarization tasks, potentially optimizing performance and cost. - Unit Tests for Summarizer: New unit tests have been added in
tests/unit/test_summarizer.pyto validate the functionality and configuration of the summarization node, ensuring its proper creation, prompt structure, and adherence to defined token limits.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and 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 to provide feedback.
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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
|
Address #14 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a summarization node to the React Agent. The review identifies an unresolved TODO comment, an unused import, trailing whitespace, and some redundant test cases. Addressing this feedback will enhance the code quality and maintainability.
| @@ -0,0 +1,102 @@ | |||
| from katalyst.katalyst_core.state import KatalystState | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added Ruff , can adress and format the formatting and other issues in a later pr
- Introduced Ruff as a development dependency for code linting and formatting. - Created a GitHub Actions workflow to automate Ruff checks on pull requests and pushes to the main branch. - Removed an unused import in the summarizer module to clean up the codebase.
- Deleted tests that verify the usage of configuration constants and output messages key in the summarization node. - Streamlined the test suite to focus on essential functionality and improve maintainability.
|
Implemented in #45 |
Description
Context engineering - Introducing Summarization Node to React Agent