@@ -16,7 +16,7 @@ export type AgentFinishReason =
1616 | 'tool_calls'
1717 /** Blocked or refused by a safety system. */
1818 | 'content_filter'
19- /** The provider reported the generation itself as malformed. */
19+ /** The provider reported the generation itself as failed or malformed. */
2020 | 'error'
2121 /** Reported, but not a case this vocabulary distinguishes. */
2222 | 'other'
@@ -41,6 +41,37 @@ const NORMALIZED_BY_RAW = new Map<string, AgentFinishReason>([
4141 // OpenAI Responses reports truncation through `incomplete_details.reason`.
4242 [ 'max_output_tokens' , 'length' ] ,
4343
44+ /** Mistral separates the model's own max length from the caller's `max_tokens`. */
45+ [ 'model_length' , 'length' ] ,
46+
47+ /**
48+ * Natural end-of-sequence. Together and HuggingFace-backed proxies report the
49+ * model's EOS token separately from a caller-supplied stop sequence, so without
50+ * these the routine success path on open-weight models is unclassified.
51+ */
52+ [ 'eos' , 'stop' ] ,
53+ [ 'eos_token' , 'stop' ] ,
54+
55+ /**
56+ * A generation the provider itself reported as failed. Mistral, OpenRouter,
57+ * Together and Fireworks all spell this `error`; the DeepSeek and Z.ai values are
58+ * the same class with a stated cause.
59+ */
60+ [ 'error' , 'error' ] ,
61+ [ 'insufficient_system_resource' , 'error' ] ,
62+ [ 'network_error' , 'error' ] ,
63+
64+ /** Z.ai (GLM) sensitive-content block. */
65+ [ 'sensitive' , 'content_filter' ] ,
66+
67+ /**
68+ * Cut short with no outcome to report, on vLLM and NIM-hosted models. vLLM treats
69+ * a repetition cutoff as a normal finish rather than a failure, so it is not
70+ * `error`.
71+ */
72+ [ 'abort' , 'other' ] ,
73+ [ 'repetition' , 'other' ] ,
74+
4475 // Anthropic Messages, shared by Bedrock's Converse API.
4576 [ 'end_turn' , 'stop' ] ,
4677 [ 'stop_sequence' , 'stop' ] ,
@@ -72,6 +103,12 @@ const NORMALIZED_BY_RAW = new Map<string, AgentFinishReason>([
72103 [ 'image_recitation' , 'content_filter' ] ,
73104 [ 'malformed_function_call' , 'error' ] ,
74105 [ 'unexpected_tool_call' , 'error' ] ,
106+ [ 'malformed_response' , 'error' ] ,
107+ [ 'missing_thought_signature' , 'error' ] ,
108+ [ 'model_armor' , 'content_filter' ] ,
109+ [ 'escalation' , 'content_filter' ] ,
110+ /** A runaway tool loop the server aborted, not a request to execute tools. */
111+ [ 'too_many_tool_calls' , 'other' ] ,
75112 [ 'language' , 'other' ] ,
76113 [ 'other' , 'other' ] ,
77114 [ 'no_image' , 'other' ] ,
0 commit comments