fix(llm): coerce None output_tokens to 0 in completion_result_to_response (#809)
Some providers return output_tokens=None on certain completions (observed with Gemini on tool-loop completions). HonchoLLMCallResponse types output_tokens as int, so the None propagates into a Pydantic validation error that aborts the call. In practice this surfaces in the Dreamer: a dream starts, deduction succeeds, then induction crashes before inductive conclusions are persisted. Coerce None -> 0 so token accounting degrades gracefully (under-counts rather than crashing) for providers that omit output token counts. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
aa993a6ddd
commit
99cbebe30e
|
|
@ -167,7 +167,7 @@ def completion_result_to_response(
|
|||
return HonchoLLMCallResponse(
|
||||
content=result.content,
|
||||
input_tokens=result.input_tokens,
|
||||
output_tokens=result.output_tokens,
|
||||
output_tokens=result.output_tokens or 0,
|
||||
cache_creation_input_tokens=result.cache_creation_input_tokens,
|
||||
cache_read_input_tokens=result.cache_read_input_tokens,
|
||||
finish_reasons=[result.finish_reason] if result.finish_reason else [],
|
||||
|
|
|
|||
Loading…
Reference in New Issue