rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:Canson666/dsh-finish-reason-patch
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
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.
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 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 finish (or tool-calls if tool-call
deltas were delivered), so the turn completes instead of aborting. This holds
whether or not content was delivered: some OpenAI-compatible gateways stream
only usage — or nothing — before ending without a finish_reason (reporting
outputTokens: 0), and they are accepted as complete empty responses instead
of retry-looping (Codex-style tolerance). All other error finishes (transport
resets, rate limits, HTTP errors, ...) pass through untouched, so the existing
retry policy still applies to genuinely broken responses.
When it fires you'll see:
[finish-reason-patch] provider finished without finish_reason -> mapped to "stop"
The plugin is a plain Cordis host plugin (exports name / apply, no external
dependencies beyond the ctx Cordis passes in).
Ship this folder as a package named dsh-finish-reason-patch:
<profile root>/node_modules/dsh-finish-reason-patch
pointing at this folder (same pattern as other local DSH plugins).package.json, add the package to
dsh.profile.bundles and to dependencies (e.g.
"dsh-finish-reason-patch": "link:<absolute path to this folder>").cordis.patch.yml inserts the plugin row automatically.Define/run the plugin host body (plugin.mjs) through the Cordis dynamic
plugin tools. It stays active until the process exits; re-run after a restart.
Effects are identical and idempotent if both routes are active.
node selftest.mjs — all 5 cases pass.Remove the bundle entry + dependency from the profile package.json, delete
the node_modules junction, restart DSH. No changes are made to any shipped
DSH file.
plugin.mjs — the plugin (llm/stream waterfall hook + rewrite logic)cordis.patch.yml — bundle patch layer (the profile-tree insert row)package.json — npm metadata (dsh.runtime: host, dsh.bundle.patch)selftest.mjs — local logic self-testLICENSE — MITCLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: 模型。