perf: decrease mem cost#757
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors session message serialization by introducing a structured pluginInStreamMessage type and using standard json.Marshal instead of a custom parser. It also moves the normalization of model properties from serialization (MarshalJSON) to deserialization (UnmarshalJSON/UnmarshalYAML) and cache retrieval steps, accompanied by new unit tests. The review feedback highlights a potential issue in Session.Message where the error from json.Marshal is ignored, which could lead to silent failures or panics if serialization fails, and suggests logging this error.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Description
fix #756
previously, ModelProperties was converted inside every MarshalJSON call:
However, because MarshalJSON was defined on a value receiver, m is a copy, so the converted result is never written back to the original object. The next serialization still repeats the conversion from scratch.
Now this is done early, after deserialization/loading, using a pointer receiver:
The original object is normalized in place, so subsequent MarshalJSON calls serialize the already-converted map[string]any directly without repeating the recursive conversion.
Type of Change
Essential Checklist
Testing
Bug Fix (if applicable)
Fixes #123orCloses #123)Additional Information
Please provide any additional context that would help reviewers understand the changes.