Skip to content

Conversation

@RheagalFire
Copy link
Collaborator

Description

Context engineering - Introducing Summarization Node to React Agent

… 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.
@RheagalFire RheagalFire requested a review from marutilai July 17, 2025 18:53
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 SummarizationNode from the langmem library, 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 SummarizationNode is integrated into the create_react_agent function as a pre_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.py to control the summarization behavior. These include MAX_AGGREGATE_TOKENS_IN_SUMMARY_AND_OUTPUT, MAX_TOKENS_TO_TRIGGER_SUMMARY, and MAX_TOKENS_IN_SUMMARY_ONLY, allowing fine-grained control over when summarization occurs and its output size.
  • Detailed Summarization Prompt: A comprehensive SUMMARIZATION_PROMPT has 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.py to include a specific summarizer role, mapping it to the execution model 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.py to 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

  1. 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.

@RheagalFire
Copy link
Collaborator Author

Address #14

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The KatalystState import is unused. Remove it to keep the code clean.

Copy link
Collaborator Author

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.
@RheagalFire RheagalFire self-assigned this Jul 17, 2025
@RheagalFire RheagalFire linked an issue Jul 17, 2025 that may be closed by this pull request
@RheagalFire
Copy link
Collaborator Author

RheagalFire commented Jul 26, 2025

Implemented in #45

@RheagalFire RheagalFire deleted the context-engineering branch July 26, 2025 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Context Management for React Agent

2 participants