Post-coordination-removal sweep: the coordination wire protocol (AgentRequest, AgentResponse, DelegationIntent, CoordinationResult, DelegationReason, TaskComplexity, ToolCallRecord, AgentTimeoutError, AgentUnavailableError, DelegationError) had zero importers left in src/ - only its own test module. AgentError stays (raised by run_librarian, mapped to user-safe failures by delegation.py). Also drops the stale coordination.py line from the README tree. Import-cycle sanity: python -c 'import src.main' passes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QbFZyDvYksazX6nYQYZ67L
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
"""
|
|
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")
|