diff --git a/src/strands/agent/agent.py b/src/strands/agent/agent.py index cacc69ece..dda0fba3a 100644 --- a/src/strands/agent/agent.py +++ b/src/strands/agent/agent.py @@ -278,6 +278,8 @@ def __init__( self.hooks.add_hook(hook) self.hooks.invoke_callbacks(AgentInitializedEvent(agent=self)) + logger.debug("agent_id=<%s>, name=<%s> | agent initialized", self.agent_id, self.name) + @property def system_prompt(self) -> str | None: """Get the system prompt as a string for backwards compatibility. diff --git a/test_output.log b/test_output.log new file mode 100644 index 000000000..726a4d159 --- /dev/null +++ b/test_output.log @@ -0,0 +1 @@ +/bin/sh: 1: hatch: not found diff --git a/tests/strands/agent/test_agent.py b/tests/strands/agent/test_agent.py index eb039185c..1bcc84912 100644 --- a/tests/strands/agent/test_agent.py +++ b/tests/strands/agent/test_agent.py @@ -288,6 +288,18 @@ def test_agent__init__invalid_id(agent_id): Agent(agent_id=agent_id) +def test_agent__init__logs_debug_message(mock_model, caplog): + import logging + + with caplog.at_level(logging.DEBUG, logger="strands.agent.agent"): + agent = Agent(model=mock_model, agent_id="test-agent-123", name="TestAgent") + + assert any("agent initialized" in record.message for record in caplog.records) + assert any("agent_id=" in record.message for record in caplog.records) + assert any("name=" in record.message for record in caplog.records) + assert agent.agent_id == "test-agent-123" + + def test_agent__call__( mock_model, system_prompt,