test: agent-less CI compat for transport-port tests

The new normalize test now stubs agent.anthropic_adapter in sys.modules
(CI has no agent package — real import raised ModuleNotFoundError), and the
issue-1013 codex fake ports to the v0.21 _get_transport contract instead of
the deleted _normalize_codex_response method.
This commit is contained in:
Sebastian B committed 2026-09-02 15:29:04 +01:00
1 parent da5703d501
commit 6a0defbc2f
2 files changed
+20 -8

No files matched your search

+9 -6
View File
@@ -68,12 +68,15 @@ def test_anthropic_title_uses_transport_normalize_response(monkeypatch):
"""
from api.streaming import generate_title_raw_via_agent
import agent.anthropic_adapter
# Mirror v0.21: the module-level normalizer is gone (no-op on v0.21 trees).
monkeypatch.delattr(
agent.anthropic_adapter, 'normalize_anthropic_response', raising=False
)
# Simulate the v0.21 adapter module in-process (works in agent-less CI too):
# it still exports build_anthropic_kwargs but deliberately does NOT define
# normalize_anthropic_response — exactly the environment this port targets.
fake_adapter = types.ModuleType('agent.anthropic_adapter')
fake_adapter.build_anthropic_kwargs = lambda **kwargs: {}
fake_agent_pkg = sys.modules.get('agent') or types.ModuleType('agent')
fake_agent_pkg.anthropic_adapter = fake_adapter
monkeypatch.setitem(sys.modules, 'agent', fake_agent_pkg)
monkeypatch.setitem(sys.modules, 'agent.anthropic_adapter', fake_adapter)
transport = _FakeTransport(TITLE_TEXT)
agent = _make_anthropic_fake_agent(transport)
+11 -2
View File
@@ -669,12 +669,21 @@ def test_handoff_summary_codex_output_cap_matches_provider_compatibility(
request_kwargs.append(kwargs)
return object()
def _normalize_codex_response(self, response):
return types.SimpleNamespace(content="- You should complete the remaining review."), "stop"
def _get_transport(self, mode=None):
# hermes-agent v0.21 contract: normalization goes through the
# provider transport (CodexTransport.normalize_response returns
# NormalizedResponse with .content); the old
# AIAgent._normalize_codex_response method no longer exists.
assert mode == "codex_responses"
return _CodexTransport()
def release_clients(self):
return None
class _CodexTransport:
def normalize_response(self, response, **kwargs):
return types.SimpleNamespace(content="- You should complete the remaining review.")
fake_run_agent = types.ModuleType("run_agent")
fake_run_agent.AIAgent = _CodexAgent
monkeypatch.setitem(sys.modules, "run_agent", fake_run_agent)