michael-han-il/dsh-llm-finish-reason-tolerance

michael-han-il★ 0JavaScriptLast synced: 2026-08-17

Open on GitHub

A DeepSeek Harness host plugin that makes the agent tolerate OpenAI-compatible providers whose streaming responses end without a finish_reason. The canonical case is the Snowflake Cortex REST API gateway.

README excerpt

dsh-llm-finish-reason-tolerance A DeepSeek Harness host plugin that makes the agent tolerate OpenAI-compatible providers whose streaming responses end without a finish reason . The canonical case is the Snowflake Cortex gateway ( .snowflakecomputing.com/api/v2/cortex/v1 ): its Chat Completions SSE streams content deltas and a terminal data: [DONE] but never sends a finish reason — not for plain text, not for tool calls (non-streaming responses return finish reason: "" ). The harness's model client (pi-ai) treats that as a truncated stream ( Stream ended without finish reason ), and the harness maps it to a TRANSPORT error finish. Every request delivers content and then fails the turn . This plugin rewrites only that specific terminal error into the successful finish the content already deserves. How it works The plugin listens on the harness's llm/stream waterfall (registered globally and prepended, so its returned iterable is the one consumers iterate) and wraps every model stream: - a tool-call block was delivered → the terminal finish becomes { kind: 'tool-calls' } - text content was delivered → the terminal finish becomes { kind: 'stop' } - nothing was delivered, or the error i…

View full README on GitHub →
Agentsdsh-plugindsh-pluginsterminalagent

Category