Skip to content

Commit 3f1f572

Browse files
committed
fix: Fix various docstring issues
1 parent ce3fe9e commit 3f1f572

File tree

6 files changed

+35
-19
lines changed

6 files changed

+35
-19
lines changed

src/strands/hooks/registry.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,12 @@ def invoke_callbacks(self, event: TInvokeEvent) -> TInvokeEvent:
184184
185185
This method finds all callbacks registered for the event's type and
186186
invokes them in the appropriate order. For events with should_reverse_callbacks=True,
187-
callbacks are invoked in reverse registration order.
187+
callbacks are invoked in reverse registration order. Any exceptions raised by callback
188+
functions will propagate to the caller.
188189
189190
Args:
190191
event: The event to dispatch to registered callbacks.
191192
192-
Raises:
193-
Any exceptions raised by callback functions will propagate to the caller.
194-
195193
Returns:
196194
The event dispatched to registered callbacks.
197195

src/strands/models/writer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ async def structured_output(
427427
"""Get structured output from the model.
428428
429429
Args:
430-
output_model(Type[BaseModel]): The output model to use for the agent.
431-
prompt(Messages): The prompt messages to use for the agent.
430+
output_model: The output model to use for the agent.
431+
prompt: The prompt messages to use for the agent.
432432
system_prompt: System prompt to provide context to the model.
433433
**kwargs: Additional keyword arguments for future extensibility.
434434
"""

src/strands/session/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Session module.
2+
3+
This module provides session management functionality.
4+
"""
5+
6+
from .file_session_manager import FileSessionManager
7+
from .repository_session_manager import RepositorySessionManager
8+
from .s3_session_manager import S3SessionManager
9+
from .session_manager import SessionManager
10+
from .session_repository import SessionRepository
11+
12+
__all__ = [
13+
"FileSessionManager",
14+
"RepositorySessionManager",
15+
"S3SessionManager",
16+
"SessionManager",
17+
"SessionRepository",
18+
]

src/strands/session/repository_session_manager.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"""Repository session manager implementation."""
22

33
import logging
4-
from typing import Any, Optional
4+
from typing import TYPE_CHECKING, Any, Optional
55

6-
from ..agent.agent import Agent
76
from ..agent.state import AgentState
87
from ..types.content import Message
98
from ..types.exceptions import SessionException
@@ -16,6 +15,9 @@
1615
from .session_manager import SessionManager
1716
from .session_repository import SessionRepository
1817

18+
if TYPE_CHECKING:
19+
from ..agent.agent import Agent
20+
1921
logger = logging.getLogger(__name__)
2022

2123

@@ -49,7 +51,7 @@ def __init__(self, session_id: str, session_repository: SessionRepository, **kwa
4951
# Keep track of the latest message of each agent in case we need to redact it.
5052
self._latest_agent_message: dict[str, Optional[SessionMessage]] = {}
5153

52-
def append_message(self, message: Message, agent: Agent, **kwargs: Any) -> None:
54+
def append_message(self, message: Message, agent: "Agent", **kwargs: Any) -> None:
5355
"""Append a message to the agent's session.
5456
5557
Args:
@@ -68,7 +70,7 @@ def append_message(self, message: Message, agent: Agent, **kwargs: Any) -> None:
6870
self._latest_agent_message[agent.agent_id] = session_message
6971
self.session_repository.create_message(self.session_id, agent.agent_id, session_message)
7072

71-
def redact_latest_message(self, redact_message: Message, agent: Agent, **kwargs: Any) -> None:
73+
def redact_latest_message(self, redact_message: Message, agent: "Agent", **kwargs: Any) -> None:
7274
"""Redact the latest message appended to the session.
7375
7476
Args:
@@ -82,7 +84,7 @@ def redact_latest_message(self, redact_message: Message, agent: Agent, **kwargs:
8284
latest_agent_message.redact_message = redact_message
8385
return self.session_repository.update_message(self.session_id, agent.agent_id, latest_agent_message)
8486

85-
def sync_agent(self, agent: Agent, **kwargs: Any) -> None:
87+
def sync_agent(self, agent: "Agent", **kwargs: Any) -> None:
8688
"""Serialize and update the agent into the session repository.
8789
8890
Args:
@@ -94,7 +96,7 @@ def sync_agent(self, agent: Agent, **kwargs: Any) -> None:
9496
SessionAgent.from_agent(agent),
9597
)
9698

97-
def initialize(self, agent: Agent, **kwargs: Any) -> None:
99+
def initialize(self, agent: "Agent", **kwargs: Any) -> None:
98100
"""Initialize an agent with a session.
99101
100102
Args:

src/strands/telemetry/tracer.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,6 @@ def end_agent_span(
473473
span: The span to end.
474474
response: The response from the agent.
475475
error: Any error that occurred.
476-
metrics: Metrics data to add to the span.
477476
"""
478477
attributes: Dict[str, AttributeValue] = {}
479478

@@ -541,9 +540,6 @@ def end_swarm_span(
541540
def get_tracer() -> Tracer:
542541
"""Get or create the global tracer.
543542
544-
Args:
545-
service_name: Name of the service for OpenTelemetry.
546-
547543
Returns:
548544
The global tracer instance.
549545
"""

src/strands/types/session.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
from dataclasses import asdict, dataclass, field
66
from datetime import datetime, timezone
77
from enum import Enum
8-
from typing import Any, Dict, Optional
8+
from typing import TYPE_CHECKING, Any, Dict, Optional
99

10-
from ..agent.agent import Agent
1110
from .content import Message
1211

12+
if TYPE_CHECKING:
13+
from ..agent.agent import Agent
14+
1315

1416
class SessionType(str, Enum):
1517
"""Enumeration of session types.
@@ -111,7 +113,7 @@ class SessionAgent:
111113
updated_at: str = field(default_factory=lambda: datetime.now(timezone.utc).isoformat())
112114

113115
@classmethod
114-
def from_agent(cls, agent: Agent) -> "SessionAgent":
116+
def from_agent(cls, agent: "Agent") -> "SessionAgent":
115117
"""Convert an Agent to a SessionAgent."""
116118
if agent.agent_id is None:
117119
raise ValueError("agent_id needs to be defined.")

0 commit comments

Comments
 (0)