Skip to content

🪲 BUG-#68: Request stream_options.include_usage in SSE streaming - #70

Merged
FernandoCelmer merged 5 commits into
masterfrom
feature/68
Aug 16, 2026
Merged

🪲 BUG-#68: Request stream_options.include_usage in SSE streaming#70
FernandoCelmer merged 5 commits into
masterfrom
feature/68

Conversation

@FernandoCelmer

@FernandoCelmer FernandoCelmer commented Aug 16, 2026

Copy link
Copy Markdown
Member

Description

  • pycodeloop/providers/generic.py — Added stream_options: {include_usage: true} to the body built in _stream(), so OpenAI-compatible servers that only emit a usage chunk when explicitly requested (e.g. Ollama) include token counts in streamed responses.
  • tests/providers/test_generic.py — Regression test asserting the outgoing request body carries stream_options.include_usage and that the usage values from the final SSE chunk (choices: []) are captured in the result.

Motivation and Context

Streamed responses always showed input_tokens: 0 / output_tokens: 0 against Ollama and other providers that require the client to opt in to usage reporting. The non-streaming path was unaffected.

Closes #68

Types of changes

  • Bug fix (change that fixes an issue)
  • New feature (change which adds functionality)
  • Documentation

Checklist

  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the CHANGELOG
  • I have updated the documentation accordingly

@FernandoCelmer FernandoCelmer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Code Review

Code issues found: 2

# Severity Comment
1 [Blocking] stream_options unconditionally overwrites caller-provided value
2 [Blocking] stream_options.include_usage sent to all SSE providers without compatibility guard

Comment thread pycodeloop/providers/generic.py Outdated
Comment thread pycodeloop/providers/generic.py Outdated
@FernandoCelmer FernandoCelmer added the bug Something isn't working label Aug 16, 2026
@FernandoCelmer
FernandoCelmer merged commit 1915143 into master Aug 16, 2026
8 checks passed
@FernandoCelmer
FernandoCelmer deleted the feature/68 branch August 16, 2026 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Usage tokens 0/0 not propagated from Ollama (and other providers) to UI

1 participant