Skip to content

Commit b55018d

Browse files
committed
feat(hooks): add TypedEvent
1 parent 0de7ae9 commit b55018d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/strands/agent/agent.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@
5656
from ..tools.registry import ToolRegistry
5757
from ..tools.structured_output._structured_output_context import StructuredOutputContext
5858
from ..tools.watcher import ToolWatcher
59-
from ..types._events import AgentResultEvent, InitEventLoopEvent, ModelStreamChunkEvent, ToolInterruptEvent, TypedEvent
59+
from ..types._events import (
60+
AgentResultEvent,
61+
EventLoopStopEvent,
62+
InitEventLoopEvent,
63+
ModelStreamChunkEvent,
64+
ToolInterruptEvent,
65+
TypedEvent,
66+
)
6067
from ..types.agent import AgentInput
6168
from ..types.content import ContentBlock, Message, Messages, SystemContentBlock
6269
from ..types.exceptions import ContextWindowOverflowException
@@ -763,7 +770,7 @@ async def _run_loop(
763770
yield event
764771

765772
# Capture the result from the final event if available
766-
if hasattr(event, "__getitem__") and "stop" in event:
773+
if isinstance(event, EventLoopStopEvent):
767774
agent_result = AgentResult(*event["stop"])
768775

769776
finally:

0 commit comments

Comments
 (0)