Bug: convertOpenAIStreamToAnthropic fails to handle usage chunk properly at stream end, causing input_tokens and output_tokens to always be 0

Author: fjenjoyCreated Jun 2, 2026Updated Sep 17, 2026

When streaming responses are being processed in convertOpenAIStreamToAnthropic, when reader.read() returns the last two chunks — the first one containing finish_reason and the second one containing usage — the latter chunk cannot be processed. As a result, input_tokens and output_tokens are returned as 0, which often prevents Claude Code from triggering context compression.

Source: musistudio/claude-code-router