Files
hermes-agent/tests
teknium1 6ed8bea80b fix(agent): refusal handler reports Anthropic stop_details instead of "(no text)"
A stop_reason=refusal from Anthropic's streaming classifier arrives with an
empty body; the reason lives on the message's stop_details (category and,
when present, an explanation). handle_content_policy_refusal now uses that
explanation (or the category) as the refusal text shown to the user and
recorded in the content_policy_blocked error, and the warning line carries
native_stop_reason + stop_details so a classifier refusal is
distinguishable from a Bedrock guardrail block (both map to content_filter;
that mapping is unchanged because turn_response_check routes it here).

The main-loop Anthropic stream returns the SDK's get_final_message()
snapshot, which copies only stop_reason/stop_sequence from message_delta;
the accumulator now keeps stop_details and _call_anthropic restores it on
the snapshot, mirroring the aux-client path fixed in the previous commit.

Part of #113689. The native-stop-reason logging follows the direction of
PR #113699 by @liuhao1024, minus the refusal content block, which the
Messages API does not emit.

Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>
2026-09-18 09:52:36 -07:00
..
…
…