Files
tatlock/tests/agents/librarian/test_agent_failures.py
T
jpmschweitzerandClaude Fable 5 31b948a748 refactor(agents): delete dead coordination/streaming delegation stack
One delegation implementation remains (src/agents/delegation.py).
Removed, after verifying zero live importers post-Phase-A/B:

- src/agents/coordination.py: CoordinationEngine, duplicate
  delegate_to_librarian, AGENT_EXECUTORS/AGENT_STREAM_EXECUTORS
  (only importer was its own test module)
- run_librarian_stream: documented-broken path (Ollama streaming +
  tool call bug, PydanticAI #1292/#2256), only called by the deleted
  coordination engine
- stream_delegate_to_* wrappers + STREAMING_DELEGATION_WRAPPERS and
  the never-parsed __DELEGATION_RESULT__ marker in delegation.py
- HouseholdRegistry.get_streaming_delegation_tools() (no callers)
- tests/agents/test_coordination.py and the wrapper/stream tests

Note: the STREAMING_DELEGATION_WRAPPERS import in
src/responses/streaming.py was already removed by Phase A (7ce1c1a);
nothing to delete there.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QbFZyDvYksazX6nYQYZ67L
2026-07-14 11:52:36 +02:00

40 lines
1.3 KiB
Python

"""
Tests for structured failure behavior of The Librarian entry point.
run_librarian must raise AgentError on failure instead of returning
error text as if it were research output, and the raised error must
not leak exception detail (internal URLs etc.).
"""
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from src.agents.librarian.agent import run_librarian
from src.agents.protocol import AgentError
@pytest.mark.unit
class TestRunLibrarianFailures:
"""run_librarian raises structured errors instead of returning text."""
@pytest.mark.asyncio
async def test_run_librarian_raises_agent_error(self):
"""Failures raise AgentError rather than returning error prose."""
mock_agent = MagicMock()
mock_agent.run = AsyncMock(
side_effect=RuntimeError("Connection refused to http://internal:8089")
)
with patch(
"src.agents.librarian.agent.get_librarian_agent",
return_value=mock_agent,
):
with pytest.raises(AgentError) as exc_info:
await run_librarian(task="Find Docker docs")
assert exc_info.value.agent_name == "librarian"
# Exception detail stays in logs only
assert "internal" not in str(exc_info.value)
assert "Connection refused" not in str(exc_info.value)