Skip to content

fix(openclaw): stream_options.include_usage for pi-ai compatibility#111

Merged
saschabuehrle merged 1 commit intomainfrom
fix/openclaw-stream-options-usage
Feb 11, 2026
Merged

fix(openclaw): stream_options.include_usage for pi-ai compatibility#111
saschabuehrle merged 1 commit intomainfrom
fix/openclaw-stream-options-usage

Conversation

@saschabuehrle
Copy link
Copy Markdown
Collaborator

Summary

Changes

  • openai_server.py: extract stream_options, pass include_usage flag, emit separate usage-only SSE chunk before [DONE]
  • test_openclaw_openai_server_streaming.py: two new tests covering include_usage on/off

Test plan

  • All 6 streaming tests pass (pytest tests/test_openclaw_openai_server_streaming.py)
  • Manual test with OpenClaw connected to cascadeflow — verify non-empty responses for both streaming and non-streaming

…pi-ai compatibility

OpenClaw's pi-ai runtime sends stream_options: {include_usage: true} and
expects a separate usage-only chunk with choices=[] before [DONE] per the
OpenAI streaming spec. Without this, the OpenAI Node SDK used by pi-ai
fails to parse the response correctly, resulting in empty content.

Also adds Connection: close header to non-streaming JSON responses.
@saschabuehrle saschabuehrle merged commit 44d2fb3 into main Feb 11, 2026
18 of 19 checks passed
@saschabuehrle saschabuehrle deleted the fix/openclaw-stream-options-usage branch February 11, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant