fix(gemini): preserve thought-only max-token responses

This commit is contained in:
ZheFox
2026-09-03 17:04:12 +08:00
parent 89fe9e9f0a
commit d78b5a81fb
2 changed files with 50 additions and 4 deletions
@@ -3745,6 +3745,35 @@ mod tests {
assert!(message.contains("visible model output"));
}
#[test]
fn invalid_gemini_provider_success_accepts_thought_only_max_tokens() {
let plan = test_gemini_chat_plan();
let body = json!({
"candidates": [{
"content": {
"role": "model",
"parts": [{"text": "hidden plan", "thought": true}]
},
"finishReason": "MAX_TOKENS"
}],
"usageMetadata": {
"promptTokenCount": 8,
"candidatesTokenCount": 0,
"thoughtsTokenCount": 24,
"totalTokenCount": 32
}
});
let message = invalid_gemini_provider_success_message(
&plan,
None,
StatusCode::OK.as_u16(),
Some(&body),
);
assert!(message.is_none());
}
#[test]
fn invalid_gemini_provider_success_error_is_retryable_candidate_failure() {
let error = invalid_gemini_provider_success_execution_error(