Skip to content

Commit f5490c1

Browse files
committed
fix
1 parent ecc109f commit f5490c1

File tree

4 files changed

+26
-36
lines changed

4 files changed

+26
-36
lines changed

src/strands/agent/base.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
from ..types.agent import AgentInput
99
from .agent_result import AgentResult
10-
from .state import AgentState
1110

1211

1312
@runtime_checkable
@@ -18,15 +17,6 @@ class AgentBase(Protocol):
1817
must satisfy.
1918
"""
2019

21-
agent_id: str
22-
"""Unique identifier for the agent."""
23-
24-
name: str
25-
"""Human-readable name of the agent."""
26-
27-
state: AgentState
28-
"""Current state of the agent."""
29-
3020
async def invoke_async(
3121
self,
3222
prompt: AgentInput = None,

src/strands/multiagent/swarm.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from opentelemetry import trace as trace_api
2424

2525
from .._async import run_async
26-
from ..agent import Agent, AgentBase
26+
from ..agent import Agent
2727
from ..agent.state import AgentState
2828
from ..experimental.hooks.multiagent import (
2929
AfterMultiAgentInvocationEvent,
@@ -57,7 +57,7 @@ class SwarmNode:
5757
"""Represents a node (e.g. Agent) in the swarm."""
5858

5959
node_id: str
60-
executor: AgentBase
60+
executor: Agent
6161
_initial_messages: Messages = field(default_factory=list, init=False)
6262
_initial_state: AgentState = field(default_factory=AgentState, init=False)
6363

@@ -212,9 +212,9 @@ class Swarm(MultiAgentBase):
212212

213213
def __init__(
214214
self,
215-
nodes: list[AgentBase],
215+
nodes: list[Agent],
216216
*,
217-
entry_point: AgentBase | None = None,
217+
entry_point: Agent | None = None,
218218
max_handoffs: int = 20,
219219
max_iterations: int = 20,
220220
execution_timeout: float = 900.0,
@@ -229,8 +229,8 @@ def __init__(
229229
230230
Args:
231231
id : Unique swarm id (default: None)
232-
nodes: List of nodes (e.g. AgentBase) to include in the swarm
233-
entry_point: AgentBase to start with. If None, uses the first agent (default: None)
232+
nodes: List of nodes (e.g. Agent) to include in the swarm
233+
entry_point: Agent to start with. If None, uses the first agent (default: None)
234234
max_handoffs: Maximum handoffs to agents and users (default: 20)
235235
max_iterations: Maximum node executions within the swarm (default: 20)
236236
execution_timeout: Total execution timeout in seconds (default: 900.0)
@@ -425,7 +425,7 @@ async def _stream_with_timeout(
425425
except asyncio.TimeoutError as err:
426426
raise Exception(timeout_message) from err
427427

428-
def _setup_swarm(self, nodes: list[AgentBase]) -> None:
428+
def _setup_swarm(self, nodes: list[Agent]) -> None:
429429
"""Initialize swarm configuration."""
430430
# Validate nodes before setup
431431
self._validate_swarm(nodes)
@@ -467,7 +467,7 @@ def _setup_swarm(self, nodes: list[AgentBase]) -> None:
467467
first_node = next(iter(self.nodes.keys()))
468468
logger.debug("entry_point=<%s> | using first node as entry point", first_node)
469469

470-
def _validate_swarm(self, nodes: list[AgentBase]) -> None:
470+
def _validate_swarm(self, nodes: list[Agent]) -> None:
471471
"""Validate swarm structure and nodes."""
472472
# Check for duplicate object instances
473473
seen_instances = set()

src/strands/session/repository_session_manager.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from .session_repository import SessionRepository
1818

1919
if TYPE_CHECKING:
20-
from ..agent.base import AgentBase
20+
from ..agent.agent import Agent
2121
from ..multiagent.base import MultiAgentBase
2222

2323
logger = logging.getLogger(__name__)
@@ -58,12 +58,12 @@ def __init__(
5858
# Keep track of the latest message of each agent in case we need to redact it.
5959
self._latest_agent_message: dict[str, Optional[SessionMessage]] = {}
6060

61-
def append_message(self, message: Message, agent: "AgentBase", **kwargs: Any) -> None:
61+
def append_message(self, message: Message, agent: "Agent", **kwargs: Any) -> None:
6262
"""Append a message to the agent's session.
6363
6464
Args:
6565
message: Message to add to the agent in the session
66-
agent: AgentBase to append the message to
66+
agent: Agent to append the message to
6767
**kwargs: Additional keyword arguments for future extensibility.
6868
"""
6969
# Calculate the next index (0 if this is the first message, otherwise increment the previous index)
@@ -77,12 +77,12 @@ def append_message(self, message: Message, agent: "AgentBase", **kwargs: Any) ->
7777
self._latest_agent_message[agent.agent_id] = session_message
7878
self.session_repository.create_message(self.session_id, agent.agent_id, session_message)
7979

80-
def redact_latest_message(self, redact_message: Message, agent: "AgentBase", **kwargs: Any) -> None:
80+
def redact_latest_message(self, redact_message: Message, agent: "Agent", **kwargs: Any) -> None:
8181
"""Redact the latest message appended to the session.
8282
8383
Args:
8484
redact_message: New message to use that contains the redact content
85-
agent: AgentBase to apply the message redaction to
85+
agent: Agent to apply the message redaction to
8686
**kwargs: Additional keyword arguments for future extensibility.
8787
"""
8888
latest_agent_message = self._latest_agent_message[agent.agent_id]
@@ -91,23 +91,23 @@ def redact_latest_message(self, redact_message: Message, agent: "AgentBase", **k
9191
latest_agent_message.redact_message = redact_message
9292
return self.session_repository.update_message(self.session_id, agent.agent_id, latest_agent_message)
9393

94-
def sync_agent(self, agent: "AgentBase", **kwargs: Any) -> None:
94+
def sync_agent(self, agent: "Agent", **kwargs: Any) -> None:
9595
"""Serialize and update the agent into the session repository.
9696
9797
Args:
98-
agent: AgentBase to sync to the session.
98+
agent: Agent to sync to the session.
9999
**kwargs: Additional keyword arguments for future extensibility.
100100
"""
101101
self.session_repository.update_agent(
102102
self.session_id,
103103
SessionAgent.from_agent(agent),
104104
)
105105

106-
def initialize(self, agent: "AgentBase", **kwargs: Any) -> None:
106+
def initialize(self, agent: "Agent", **kwargs: Any) -> None:
107107
"""Initialize an agent with a session.
108108
109109
Args:
110-
agent: AgentBase to initialize from the session
110+
agent: Agent to initialize from the session
111111
**kwargs: Additional keyword arguments for future extensibility.
112112
"""
113113
if agent.agent_id in self._latest_agent_message:

src/strands/session/session_manager.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from ..types.content import Message
1515

1616
if TYPE_CHECKING:
17-
from ..agent.base import AgentBase
17+
from ..agent.agent import Agent
1818
from ..multiagent.base import MultiAgentBase
1919

2020
logger = logging.getLogger(__name__)
@@ -48,40 +48,40 @@ def register_hooks(self, registry: HookRegistry, **kwargs: Any) -> None:
4848
registry.add_callback(AfterMultiAgentInvocationEvent, lambda event: self.sync_multi_agent(event.source))
4949

5050
@abstractmethod
51-
def redact_latest_message(self, redact_message: Message, agent: "AgentBase", **kwargs: Any) -> None:
51+
def redact_latest_message(self, redact_message: Message, agent: "Agent", **kwargs: Any) -> None:
5252
"""Redact the message most recently appended to the agent in the session.
5353
5454
Args:
5555
redact_message: New message to use that contains the redact content
56-
agent: AgentBase to apply the message redaction to
56+
agent: Agent to apply the message redaction to
5757
**kwargs: Additional keyword arguments for future extensibility.
5858
"""
5959

6060
@abstractmethod
61-
def append_message(self, message: Message, agent: "AgentBase", **kwargs: Any) -> None:
61+
def append_message(self, message: Message, agent: "Agent", **kwargs: Any) -> None:
6262
"""Append a message to the agent's session.
6363
6464
Args:
6565
message: Message to add to the agent in the session
66-
agent: AgentBase to append the message to
66+
agent: Agent to append the message to
6767
**kwargs: Additional keyword arguments for future extensibility.
6868
"""
6969

7070
@abstractmethod
71-
def sync_agent(self, agent: "AgentBase", **kwargs: Any) -> None:
71+
def sync_agent(self, agent: "Agent", **kwargs: Any) -> None:
7272
"""Serialize and sync the agent with the session storage.
7373
7474
Args:
75-
agent: AgentBase who should be synchronized with the session storage
75+
agent: Agent who should be synchronized with the session storage
7676
**kwargs: Additional keyword arguments for future extensibility.
7777
"""
7878

7979
@abstractmethod
80-
def initialize(self, agent: "AgentBase", **kwargs: Any) -> None:
80+
def initialize(self, agent: "Agent", **kwargs: Any) -> None:
8181
"""Initialize an agent with a session.
8282
8383
Args:
84-
agent: AgentBase to initialize
84+
agent: Agent to initialize
8585
**kwargs: Additional keyword arguments for future extensibility.
8686
"""
8787

0 commit comments

Comments
 (0)