mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-18 09:51:59 +00:00
test(transports): lock in content_filter passthrough for OpenRouter
OpenRouter (and every other OpenAI-compatible provider) uses the default
chat_completions transport, so it is already covered by the refusal fix:
an upstream Claude / moderation refusal arrives as
finish_reason="content_filter" (often empty content, no message.refusal).
Add a regression test asserting the transport passes that finish reason
straight through to the loop's content_filter handler.
(cherry picked from commit 60168a513b)
This commit is contained in:
parent
bb46bf8ce4
commit
ab26541b9a
1 changed files with 22 additions and 0 deletions
|
|
@ -900,6 +900,28 @@ class TestChatCompletionsNormalize:
|
|||
assert nr.content == "declined"
|
||||
assert nr.provider_data == {"refusal": "declined"}
|
||||
|
||||
def test_explicit_content_filter_finish_reason_passes_through(self, transport):
|
||||
"""OpenRouter (and other OpenAI-compatible providers) surface an
|
||||
upstream Claude / moderation refusal as ``finish_reason="content_filter"``
|
||||
— often with empty content and no ``message.refusal`` field. The
|
||||
transport must pass that finish reason straight through so the loop's
|
||||
content_filter refusal handler fires; no ``message.refusal`` required.
|
||||
This is the OpenRouter coverage path (OpenRouter uses the default
|
||||
chat_completions transport)."""
|
||||
r = SimpleNamespace(
|
||||
choices=[SimpleNamespace(
|
||||
message=SimpleNamespace(
|
||||
content=None, tool_calls=None, reasoning_content=None,
|
||||
refusal=None,
|
||||
),
|
||||
finish_reason="content_filter",
|
||||
)],
|
||||
usage=None,
|
||||
)
|
||||
nr = transport.normalize_response(r)
|
||||
assert nr.finish_reason == "content_filter"
|
||||
assert nr.content is None
|
||||
|
||||
def test_refusal_does_not_clobber_existing_content(self, transport):
|
||||
"""If the model emitted partial text *and* a refusal, keep the visible
|
||||
text as content but still flag the refusal via content_filter."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue