""" Tests for the agent error protocol. """ import pytest from src.agents.protocol import AgentError @pytest.mark.unit class TestAgentError: """Tests for the AgentError exception.""" def test_agent_error_defaults(self): """Test base AgentError with default agent name.""" error = AgentError("Something went wrong") assert "Something went wrong" in str(error) assert error.agent_name == "unknown" def test_agent_error_carries_agent_name(self): """Agent name is stored and prefixed into the message.""" error = AgentError("Research task failed", agent_name="librarian") assert error.agent_name == "librarian" assert str(error) == "[librarian] Research task failed" assert error.message == "Research task failed" def test_agent_error_is_catchable_as_exception(self): """AgentError participates in normal exception handling.""" with pytest.raises(AgentError): raise AgentError("boom", agent_name="librarian")