fix: handle None state values in skill_toolset after session rewind#5204
Open
enjoykumawat wants to merge 1 commit intogoogle:mainfrom
Open
fix: handle None state values in skill_toolset after session rewind#5204enjoykumawat wants to merge 1 commit intogoogle:mainfrom
enjoykumawat wants to merge 1 commit intogoogle:mainfrom
Conversation
Session rewind sets state keys to None as deletion markers. dict.get() returns None (not the default) when the key exists with value None, causing list(None) to raise TypeError. Change `state.get(key, [])` to `state.get(key) or []` at both call sites so that explicit None values fall back to an empty list. Github-Issue: google#5193 Reported-by: SAMFVH
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
Fixes #5193 — After session rewind,
LoadSkillTool.run_asynccrashes withTypeError: 'NoneType' object is not iterable.Root cause: Session rewind sets
adk_activated_skill_{agent_name}toNoneas a deletion marker.dict.get(key, default)only returns the default when the key is absent — when the key exists with valueNone, it returnsNone. Solist(None)raisesTypeError.Fix: Change
state.get(state_key, [])tostate.get(state_key) or []at both call sites (lines 155 and 794) so that explicitNonevalues fall back to an empty list.As identified by @surajksharma07 in the issue comments and confirmed in production by @SAMFVH.
Changes
src/google/adk/tools/skill_toolset.py: Fix bothstate.get()calls to handle explicitNoneTest plan
test_skill_toolset.pytests pass