Repository navigation
fix(sessions): keep SQLite session state numbers exact across updates - #7426
Closed
donggyun112 wants to merge 1 commit into
Closed
donggyun112 wants to merge 1 commit into
donggyun112 wants to merge 1 commit into
Conversation
SqliteSessionService merges a state delta by rebuilding the row from json_each values, and json_group_object writes every REAL with 15 significant digits. Each merge rewrote every key in the row, so floats such as 0.1 + 0.2 or a time.time() value were rounded even when the delta never touched them. Write a REAL with 17 digits when 15 do not read back as the same value, so floats round-trip while short values such as 19.99 keep their form.
copybara-service Bot
pushed a commit
that referenced
this pull request
Oct 8, 2026
Merge #7426 PiperOrigin-RevId: 996043876
Collaborator
|
Thank you @donggyun112 for your contribution! 🎉 Your changes have been successfully imported and merged via Copybara in commit 13787a5. Closing this PR as the changes are now in the main branch. |
This was referenced Oct 16, 2026
9 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SqliteSessionServicemerges a state delta in SQL by rebuilding the row fromjson_eachvalues (_MERGE_STATE_SQL), andjson_group_objectwrites every REAL back with 15 significant digits. Every key in the row is rewritten on each merge, not just the delta's:0.1 + 0.2reads back as0.3and atime.time()value loses its last digits.adk webuses this service by default; the in-memory and database services keep the values exact.Write a REAL with 17 significant digits when 15 do not read back as the same value. Floats round-trip, and values that already fit in 15 digits, such as
19.99, are stored as before. The merge stays a single linear pass. Integers beyond 64 bits are still parsed as REAL by SQLite and are not covered here.Testing Plan
Unit tests
New contract tests run on every backend: floats stored earlier and floats written by a delta read back unchanged in session,
user:andapp:state. On main they fail forsqliteandper_agent_databaseonly.Manual E2E
adk api_serverwith the default local store and an agent that saves a charged amount (1.05 * 1.1) to state, then refunds against the gateway amount on the next turn. On main the state holds1.155and the refund fails the amount check; with this change it holds1.1550000000000002and the refund goes through.