fix: concatenate list values in deep_merge_dicts during parallel tool call merge#5191
Open
enjoykumawat wants to merge 4 commits intogoogle:mainfrom
Open
fix: concatenate list values in deep_merge_dicts during parallel tool call merge#5191enjoykumawat wants to merge 4 commits intogoogle:mainfrom
enjoykumawat wants to merge 4 commits intogoogle:mainfrom
Conversation
… call merge When multiple tool calls run in parallel and each writes to the same state_delta key containing a list value, deep_merge_dicts silently drops all but the last value because lists hit the else branch and get overwritten. Add a list-type check so that list values are concatenated instead of overwritten, preserving all entries from parallel function responses. Fixes google#5190
wuliang229
reviewed
Apr 7, 2026
Collaborator
There was a problem hiding this comment.
Please move the tests to test_functions_parallel.py
…nctions_parallel Move tests for deep_merge_dicts and merge_parallel_function_response_events with list state_delta merging from test_functions_simple.py to test_functions_parallel.py per reviewer feedback.
Author
|
Done! Moved all the |
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.
Summary
state_deltakey containing a list value,deep_merge_dictssilently drops all but the last value because lists hit theelsebranch and get overwritten.deep_merge_dictsso list values are concatenated (d1[key] + value) instead of overwritten, preserving all entries from parallel function responses.merge_parallel_function_response_eventswithstate_deltalists.Reproduction
Test plan
test_deep_merge_dicts_*andtest_merge_parallel_function_response_events_merges_state_delta_lists)test_functions_simple.pypass (0 regressions)Fixes #5190