Skip to content

Stream tool calls and reasoning, not just message text - #329

Closed
codelion wants to merge 1 commit into
mainfrom
fix/stream-tool-calls
Closed

codelion wants to merge 1 commit into
mainfrom
fix/stream-tool-calls

Conversation

@codelion

Copy link
Copy Markdown
Member

When a client sends stream: true, the proxy and none paths re-emit the finished completion with generate_streaming_response(extract_contents(...)), which keeps only message.content.

  • A tool call has empty content, so streaming agents get a bare data: [DONE] and see an empty reply.
  • Models that answer in reasoning lose that text as well.

This adds generate_streaming_completion, which streams the whole message: content, reasoning / reasoning_content, and tool_calls with the per-call index that the OpenAI streaming format requires, plus usage in a final chunk.

Found by pointing OptiQ Code at an optillm proxy (--approach proxy): every turn came back empty. With the patch the same streamed request returns the tool call.

Tests: tests/test_streaming_completion.py (tool calls, text + reasoning, a list of completions).

🤖 Generated with Claude Code

When a client asks for stream: true, the proxy and `none` paths re-emit the
finished completion through generate_streaming_response(extract_contents(...)),
which keeps only message.content. A tool call has empty content, so streaming
agents (OptiQ Code, the OptiQ Lab, most coding agents) received a bare [DONE]
and saw an empty reply; models that answer in `reasoning` lost that too.

generate_streaming_completion streams the whole message instead: content,
reasoning / reasoning_content, and tool_calls with the per-call index the
OpenAI streaming format requires, plus usage in a final chunk.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codelion codelion closed this Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant