fix(translator): map Claude "refusal" stop_reason to content_filter and surface its explanation

Anthropic's API-level refusal (streaming classifier / ToS) ends the stream
with stop_reason "refusal", stop_details carrying the reason, zero output
tokens and no content blocks. Map refusal to content_filter in both
directions, surface stop_details.explanation as message text, and add
CLAUDE_STOP.REFUSAL to schema.
This commit is contained in:
Welington
2026-09-22 15:25:09 +07:00
parent 1a02713150
commit 0f488c7027
5 changed files with 97 additions and 0 deletions

View File

@@ -14,6 +14,9 @@ export const CLAUDE_STOP = {
MAX_TOKENS: "max_tokens",
TOOL_USE: "tool_use",
STOP_SEQUENCE: "stop_sequence",
// Anthropic's API-level refusal (streaming classifier / ToS). Arrives in
// message_delta with zero output tokens; stop_details carries the reason.
REFUSAL: "refusal",
};
// Gemini finishReason values.