File tree Expand file tree Collapse file tree 4 files changed +41
-2
lines changed
Expand file tree Collapse file tree 4 files changed +41
-2
lines changed Original file line number Diff line number Diff line change 6666SelfAgent = TypeVar ('SelfAgent' , bound = 'BaseAgent' )
6767
6868
69+ @experimental
70+ class BaseAgentState (BaseModel ):
71+ """Base class for all agent states."""
72+
73+ model_config = ConfigDict (
74+ extra = 'forbid' ,
75+ )
76+
77+
6978class BaseAgent (BaseModel ):
7079 """Base class for all agents in Agent Development Kit."""
7180
Original file line number Diff line number Diff line change 2121from typing import ClassVar
2222from typing import Dict
2323from typing import Optional
24- from typing import Type
2524
2625from typing_extensions import override
2726
3029from ..utils .context_utils import Aclosing
3130from ..utils .feature_decorator import experimental
3231from .base_agent import BaseAgent
32+ from .base_agent import BaseAgentState
3333from .base_agent_config import BaseAgentConfig
3434from .loop_agent_config import LoopAgentConfig
3535
3636
37+ @experimental
38+ class LoopAgentState (BaseAgentState ):
39+ """State for LoopAgent."""
40+
41+ current_sub_agent : str = ''
42+ """The name of the current sub-agent to run in the loop."""
43+
44+ times_looped : int = 0
45+ """The number of times the loop agent has looped."""
46+
47+
3748class LoopAgent (BaseAgent ):
3849 """A shell agent that run its sub-agents in a loop.
3950
Original file line number Diff line number Diff line change 2424
2525from ..events .event import Event
2626from ..utils .context_utils import Aclosing
27+ from ..utils .feature_decorator import experimental
2728from .base_agent import BaseAgent
28- from .base_agent import BaseAgentConfig
29+ from .base_agent import BaseAgentState
30+ from .base_agent_config import BaseAgentConfig
2931from .invocation_context import InvocationContext
3032from .llm_agent import LlmAgent
3133from .sequential_agent_config import SequentialAgentConfig
3234
3335
36+ @experimental
37+ class SequentialAgentState (BaseAgentState ):
38+ """State for SequentialAgent."""
39+
40+ current_sub_agent : str = ''
41+ """The name of the current sub-agent to run."""
42+
43+
3444class SequentialAgent (BaseAgent ):
3545 """A shell agent that runs its sub-agents in sequence."""
3646
Original file line number Diff line number Diff line change 1414
1515from __future__ import annotations
1616
17+ from typing import Any
1718from typing import Optional
1819
1920from google .genai .types import Content
@@ -95,3 +96,11 @@ class EventActions(BaseModel):
9596
9697 compaction : Optional [EventCompaction ] = None
9798 """The compaction of the events."""
99+
100+ end_of_agent : Optional [bool ] = None
101+ """If true, the current agent has finished its current run. Note that there
102+ can be multiple events with end_of_agent=True for the same agent within one
103+ invocation when there is a loop."""
104+
105+ agent_state : Optional [dict [str , Any ]] = None
106+ """The agent state at the current event."""
You can’t perform that action at this time.
0 commit comments