mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
chore: Delegate the agent state reset logic to LoopAgent
This is so we don't need to worry about side effect of Loop in all agent type. Custom agent should do the same if there exists loop inside. PiperOrigin-RevId: 818766305
This commit is contained in:
committed by
Copybara-Service
parent
214986ebeb
commit
bb1ea74924
@@ -390,6 +390,40 @@ class TestInvocationContextWithAppResumablity:
|
||||
assert 'agent1' not in invocation_context.agent_states
|
||||
assert 'agent1' not in invocation_context.end_of_agents
|
||||
|
||||
def test_reset_sub_agent_states(self):
|
||||
"""Tests that reset_sub_agent_states resets sub-agent states."""
|
||||
sub_sub_agent_1 = BaseAgent(name='sub_sub_agent_1')
|
||||
sub_agent_1 = BaseAgent(name='sub_agent_1', sub_agents=[sub_sub_agent_1])
|
||||
sub_agent_2 = BaseAgent(name='sub_agent_2')
|
||||
root_agent = BaseAgent(
|
||||
name='root_agent', sub_agents=[sub_agent_1, sub_agent_2]
|
||||
)
|
||||
|
||||
invocation_context = self._create_test_invocation_context(
|
||||
ResumabilityConfig(is_resumable=True)
|
||||
)
|
||||
invocation_context.agent = root_agent
|
||||
invocation_context.set_agent_state(
|
||||
'sub_agent_1', agent_state=BaseAgentState()
|
||||
)
|
||||
invocation_context.set_agent_state('sub_agent_2', end_of_agent=True)
|
||||
invocation_context.set_agent_state(
|
||||
'sub_sub_agent_1', agent_state=BaseAgentState()
|
||||
)
|
||||
|
||||
assert 'sub_agent_1' in invocation_context.agent_states
|
||||
assert 'sub_agent_2' in invocation_context.end_of_agents
|
||||
assert 'sub_sub_agent_1' in invocation_context.agent_states
|
||||
|
||||
invocation_context.reset_sub_agent_states('root_agent')
|
||||
|
||||
assert 'sub_agent_1' not in invocation_context.agent_states
|
||||
assert 'sub_agent_1' not in invocation_context.end_of_agents
|
||||
assert 'sub_agent_2' not in invocation_context.agent_states
|
||||
assert 'sub_agent_2' not in invocation_context.end_of_agents
|
||||
assert 'sub_sub_agent_1' not in invocation_context.agent_states
|
||||
assert 'sub_sub_agent_1' not in invocation_context.end_of_agents
|
||||
|
||||
|
||||
class TestFindMatchingFunctionCall:
|
||||
"""Test suite for find_matching_function_call."""
|
||||
|
||||
Reference in New Issue
Block a user