This repository has been archived on 2026-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
ollie-core/backend
Levi Neely cd95e2f065 backend/openai: fix streaming token counts always zero
OpenAI sends usage in a separate trailing SSE chunk, not in the same
chunk that carries finish_reason. The previous code read wire.Usage
from the finish_reason chunk (where it is always zero) and discarded
all subsequent chunks.

Fixes:
- Add stream_options:{include_usage:true} to the request so OpenAI
  actually includes usage in the stream at all.
- Accumulate usage across every chunk instead of reading it once at
  finish_reason time.
- On the Done event, use the accumulated usage rather than the
  (always-zero) usage from the finish_reason chunk.
- Keep processing chunks after finish_reason until data:[DONE] so
  the trailing usage chunk is not silently dropped.
2026-04-01 13:16:31 +02:00
..
backend.go Add streaming support for bot output and tool execution 2026-04-01 12:52:58 +02:00
new.go Remove openrouter backend alias 2026-04-01 00:57:18 +02:00
ollama.go Add streaming support for bot output and tool execution 2026-04-01 12:52:58 +02:00
openai.go backend/openai: fix streaming token counts always zero 2026-04-01 13:16:31 +02:00