Skip to content

Commit 354e0ba

Browse files
committed
fix(aws-strands): exclude hooks from template kwarg propagation
1 parent 804484b commit 354e0ba

2 files changed

Lines changed: 4 additions & 23 deletions

File tree

integrations/aws-strands/python/src/ag_ui_strands/agent.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,10 @@ def __init__(
6565
if hasattr(agent, "record_direct_tool_call")
6666
else True,
6767
}
68-
for _attr in (
69-
"trace_attributes",
70-
"agent_id",
71-
"conversation_manager",
72-
"callback_handler",
73-
"hooks",
74-
"session_manager",
75-
"tool_executor",
76-
):
77-
if hasattr(agent, _attr):
78-
self._agent_kwargs[_attr] = getattr(agent, _attr)
68+
if hasattr(agent, "trace_attributes") and agent.trace_attributes:
69+
self._agent_kwargs["trace_attributes"] = agent.trace_attributes
70+
if hasattr(agent, "agent_id") and agent.agent_id:
71+
self._agent_kwargs["agent_id"] = agent.agent_id
7972
if hasattr(agent, "state") and agent.state is not None:
8073
self._agent_kwargs["state"] = agent.state._state
8174

integrations/aws-strands/python/tests/test_template_agent_propagation.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,6 @@ def test_agent_id_captured(self):
8989
)
9090
assert ag._agent_kwargs["agent_id"] == "my-agent-id"
9191

92-
def test_conversation_manager_captured(self):
93-
"""conversation_manager from the template must appear in _agent_kwargs."""
94-
from strands.agent.conversation_manager import NullConversationManager
95-
cm = NullConversationManager()
96-
template = Agent(model=_mock_model(), conversation_manager=cm)
97-
ag = StrandsAgent(template, name="test")
98-
99-
assert "conversation_manager" in ag._agent_kwargs, (
100-
"conversation_manager not captured — new threads use a different manager"
101-
)
102-
assert ag._agent_kwargs["conversation_manager"] is cm
103-
10492
def test_initial_state_captured(self):
10593
"""Initial state from the template must be preserved for new threads."""
10694
template = Agent(model=_mock_model(), state={"greeting": "hello", "count": 0})

0 commit comments

Comments
 (0)