feat: Add max tokens exceeded to stop reasons [LET-6480] (#6576)

This commit is contained in:
Kevin Lin
2025-12-14 14:39:23 -08:00
committed by Caren Thomas
parent efac48e9ea
commit 4b9485a484
5 changed files with 33 additions and 1 deletions

View File

@@ -656,7 +656,15 @@ class OpenAIClient(LLMClientBase):
reasoning_summary_parts = None
reasoning_content_signature = None
tool_calls = None
finish_reason = "stop" if (response_data.get("status") == "completed") else None
# Check for incomplete_details first (e.g., max_output_tokens reached)
incomplete_details = response_data.get("incomplete_details")
if incomplete_details and incomplete_details.get("reason") == "max_output_tokens":
finish_reason = "length"
elif response_data.get("status") == "completed":
finish_reason = "stop"
else:
finish_reason = None
# Optionally capture reasoning presence
found_reasoning = False