Canson666/dsh-finish-reason-patch

Canson666★ 0JavaScript最后同步: 2026-08-20

在 GitHub 打开

将gpt之类的项目在dsh中出现without finish reason的情况解决,可以正常使用gpt模型

README 摘要

dsh-finish-reason-patch DSH plugin: stop agent turns from being aborted when an OpenAI-compatible provider (GPT-family models, gateways, proxies) ends a streaming response with full output but without a terminal finish reason . The bug it fixes DSH routes OpenAI-compatible providers through @earendil-works/pi-ai . When the wire stream ends without ever seeing choices[].finish reason , pi-ai raises Stream ended without finish reason ( openai-completions.js:438 ). By that point every content block is already closed and delivered — the response is complete, only the terminal marker is missing. pi-ai surfaces that as an error event, the dsh-llm-pi-ai adapter maps it to a terminal finish {kind:'error', code:'TRANSPORT'} chunk, and the agent loop ( dsh-agent-loop ) throws — aborting a perfectly good model turn. Other agents (e.g. Codex) tolerate the same wire behavior by treating end-of-stream as the end of the response. The fix The plugin hooks the llm/stream waterfall — every model call (agent turns, session-title requests, prepared calls, subagents) flows through it via LlmRuntime.streamWithRegistration . When the terminal finish is exactly that error, it is rewritten to a normal stop…

在 GitHub 查看完整 README →
工具/开发dsh-pluginterminalagent

分类