Keep the temp: state keys in the in-memory context session#4501
Keep the temp: state keys in the in-memory context session#4501ashubham wants to merge 3 commits intogoogle:mainfrom
Conversation
Summary of ChangesHello @ashubham, 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 resolves an issue where 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
|
There was a problem hiding this comment.
Code Review
This pull request aims to preserve temporary (temp:) state keys in the in-memory session context, so they can be accessed by downstream consumers during an invocation. The change correctly removes the filtering of temp: keys when updating the session state. I've added a suggestion to simplify the updated code.
I've also identified a potential issue where temp: state passed via run_async(state_delta=...) might still be stripped before updating the in-memory session. The new unit test covers state set via callbacks, but not this initial state-passing scenario. I've left a comment with a suggestion to add a test case for this to ensure the feature is complete.
There was a problem hiding this comment.
Code Review
This pull request modifies the session handling logic to keep temporary (temp:) state keys in the in-memory session context throughout an invocation. This allows downstream consumers like plugins and callbacks to access these temporary values. The changes ensure that these temporary keys are still stripped before being persisted, preventing them from being stored long-term. The implementation is clean and the logic is sound. The accompanying unit tests are comprehensive and correctly validate the new behavior, including both setting temporary state within a callback and passing it via run_async. My review found a minor improvement opportunity in the new tests to remove unused variables.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request correctly modifies the session handling logic to allow temporary state variables (prefixed with temp:) to be accessible within the in-memory session for the duration of an invocation, without persisting them. The changes in BaseSessionService are logical and improve code clarity by centralizing the filtering of temporary keys. The addition of comprehensive unit tests in test_runners.py effectively validates the new behavior from multiple angles, ensuring that temporary state is available in callbacks but excluded from the persisted session and event history. The implementation is clean and the tests are thorough. Great work!
This enables downstream consumers to read temp: state values when set during invocation start.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
When
temp:state values are set during invocation start (run_async), these get stripped out for downstream consumers. Making the utility of these variables marginal as stated in the above issues.Solution:
Do not strip the
temp:keys from the in memorysession.state. These are still stripped from thestate_deltapersisted in the session store.Testing Plan
Unit Tests:
Manual End-to-End (E2E) Tests:
run_async, pass atemp:teststate_delta.temp:testinside a lifecycle callback likebefore_agent_callback.Checklist