Ollama v0.30.1: llama-server の SSE ping コメントを無視するバグ修正 v0.30.1: llm: ignore llama-server SSE ping comments (#16443)
- Ollama v0.30.1 がリリースされ、llama.cpp b9478 で導入されたデフォルト30秒間隔の SSE ping コメントフレームを JSON として誤解析していた不具合が修正された。
- ストリーミング中にコロンのみの SSE コメント行をスキップするよう処理が改善されている。
English summary
- llama.cpp b9478 added a default 30s SSE ping that emits colon-only comment frames (":\n\n") while streamed requests are idle; Ollama treated non-data SSE lines as JSON, so skip SSE comments in complet
Ollama v0.30.1 は小規模ながら実用上重要なバグ修正リリースだ。ストリーミング推論中に発生していた SSE (Server-Sent Events) コメントの誤処理問題を解消している。
きっかけは llama.cpp のビルド b9478 で導入された仕様変更にある。llama.cpp はバックエンドの llama-server が SSE ストリームをアイドル状態のまま保持する際、30秒ごとにコロンのみからなるコメントフレーム(「:
」)を送出するデフォルト動作を追加した。これは SSE プロトコルの仕様上合法なハートビート機構であり、HTTP 接続がタイムアウトしないよう維持するための一般的な手法だ。
しかし Ollama 側のコードはこうした「データを持たない SSE 行」の存在を想定していなかった。データ行以外の SSE 行を受け取ると、それを JSON テキストとして解析しようとしてエラーが発生していた。結果として、推論が長引いた際やネットワーク遅延が大きい環境でストリーミングが途中で失敗する可能性があった。
Ollama v0.30.1 がリリースされ、llama.cpp b9478 で導入されたデフォルト30秒間隔の SSE ping コメントフレームを JSON として誤解析していた不具合が修正された。
v0.30.1 での修正は概念的にはシンプルで、SSE ストリームを処理するコードパスにおいてコロンで始まるコメント行を検出した場合は読み飛ばす処理を追加したものとみられる。これにより llama-server が送出する ping コメントが Ollama の JSON パーサーに到達しなくなり、ストリーミングが安定して継続するようになる。
SSE はもともと W3C が定めた軽量なサーバープッシュ規格で、WebSocket と異なり一方向通信のみをサポートする。LLM のトークンストリーミングとの相性が良く、OpenAI API をはじめ多くの推論サーバーが採用している。コメント行(コロン始まり)はクライアント側が無視すべきとプロトコル仕様に明記されており、今回の問題は Ollama がその仕様を厳密に実装していなかった点に起因する。
llama.cpp は活発に開発が続くオープンソースプロジェクトであり、Ollama はそのバックエンドとして利用している。アップストリームの変更が下流プロダクトに予期せぬ影響をもたらすことはオープンソースエコシステムでは珍しくなく、今回のケースはその典型例といえる。迅速なパッチリリースは Ollama チームの対応力を示すものでもある。ローカル LLM を長時間稼働させるユーザーにとっては、このアップデートを適用することでストリーミングの安定性が向上する可能性がある。
Ollama v0.30.1 is a focused patch release that addresses a subtle but impactful bug in how the application handles Server-Sent Events (SSE) streams from its llama-server backend during active inference requests.
The root cause traces back to llama.cpp build b9478, which introduced a new default behavior: when llama-server keeps an SSE stream open but is momentarily idle between streamed tokens, it now emits a colon-only comment frame — literally ":\n\n" — every 30 seconds. This is a standard SSE heartbeat technique, explicitly permitted by the W3C SSE specification, and is commonly used to prevent HTTP connections from timing out at the proxy or load balancer layer.
The problem was that Ollama's SSE consumer did not account for these comment-only lines. According to the SSE spec, any line beginning with a colon is a comment and should be silently ignored by the client. Ollama's code, however, was treating all incoming lines as potential JSON data. When a colon-only ping arrived, the JSON parser would encounter invalid input and throw an error, which could abruptly terminate a streaming completion request — particularly during longer inference runs or on slower hardware where token generation pauses are more pronounced.
The fix in v0.30.1 is straightforward in concept: the SSE processing logic now detects lines beginning with a colon and skips them before any JSON parsing occurs. This brings Ollama's SSE handling into full conformance with the protocol specification and makes streaming robust against the new llama-server ping behavior.
This kind of upstream-induced regression is a familiar challenge in the open-source ecosystem. llama.cpp moves quickly, with frequent builds that introduce new features or behavioral changes, and downstream consumers like Ollama must track those changes carefully. The 30-second ping was a reasonable addition on the llama.cpp side — it improves connection stability in networked deployments — but it exposed a gap in Ollama's SSE parsing assumptions.
SSE itself is a lightweight W3C standard designed for unidirectional server-to-client push over plain HTTP. It has become the de facto transport for LLM token streaming, used by OpenAI's API, Anthropic's Claude, and most open-source inference servers. Its simplicity — newline-delimited text, no binary framing — makes it easy to implement, but edge cases like comment lines are easy to overlook when building a consumer quickly.
For users running Ollama locally, especially those performing long-form generation tasks or operating in environments with network middleboxes, upgrading to v0.30.1 is advisable. The fix eliminates a class of streaming failures that could be difficult to diagnose, since the symptom — a dropped stream mid-generation — might be mistaken for a model error or a resource exhaustion issue rather than a protocol parsing bug.
本ページの本文・要約は AI による自動生成です。正確性は元記事 (github.com) をご確認ください。