Repository navigation
Replies: 5 comments 4 replies
|
Confirmed in the published 0.2.2-rc.3 packages — both halves hold, and I'd add one structural fix. Checked against function stopReason(raw) {
switch (raw) {
case "end_turn":
case "stop_sequence": return { kind: "stop" };
case "tool_use": return { kind: "tool-calls" };
case "max_tokens": return { kind: "max-tokens" };
default: return malformed(`unsupported stop reason ${String(raw)}`);
}
}There is no On the retry half, I agree, and there is a sharper reason to state: in this adapter One structural addition. The defect exists because the switch and the wire union drifted apart silently. A test asserting that every literal in the provider's stop-reason schema has a mapping — or an explicit, deliberate fallback — would have failed at the commit that added What I did not check, stated so it does not read as more than it is: I could not locate the client-side |
|
Thanks — the adapter-level confirmation is the piece we could not do from outside. Three follow-ups:
const CONTINUABLE_FAILURES = new Set([
"RATE_LIMIT", "SERVER", "TIMEOUT", "TRANSPORT", "EMPTY_RESPONSE", "STREAM_CLOSED"
])
Agreed on the ordering as well: mapping first; the retry whitelist is a symptom, not the defect. |
|
Confirmed on my side too — it's in the published Your exhaustiveness shape is better than mine. "Maps to a non-error finish reason, One symmetric addition, because it's the half that actually failed here: the same Worth noting why this gap survived: the codes are produced in the adapters and Agreed on ordering: mapping first; the retry whitelist is downstream of it. |
|
rc.4 looks like it addresses this from a different angle than the mapping, and I wanted to flag The fix is at the error layer rather than the stop-reason layer: a refusal now throws What hasn't changed is the recoverability half. In Worth noting for the test we discussed: the exhaustiveness shape over stop-reason literals would No action implied if the recovery half is deliberate or queued for later; I just didn't want the |
|
The stop-reason analysis in this thread matches what we measured, so I want to share a stopgap that can be installed today. dsh-llm-refusal-fix — a DSH profile bundle that vendors the Messages adapter and fixes the contract rather than the symptom:
Mapping (what a turn now ends as):
Routing: the bundle disables the built-in Evidence:
Caveat: this is a local workaround for the 0.2.2 line, not a proposed upstream implementation — once the real fix lands (refusal mapped to a terminal/recoverable state, and something in |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Environment
0.2.2-rc.3(all bundled packages report the same)app.asar209,021,953 B, build time 2026-11-13 15:30:52deepseek-officialdeepseek-flashDeepSeek Messagesstream (SSE)mode=normal,maxRetries=5,retryableCodes=[EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT],initialDelayMs=500,maxDelayMs=10000,jitterRatio=0.1MALFORMED_RESPONSEinjected by a community bundle patch (billion-contextPR #2610)Summary
Two defects, independent of each other:
refusalis a legal member of the wire schema, but the client's translation layer has no case for it, falls through todefault, and raisesmalformed("unsupported stop reason refusal"). The refusal is then recorded as a protocol violation, the turn endserror, and becauseMALFORMED_RESPONSEis absent fromCONTINUABLE_FAILURESthe UI offers no "continue" affordance. From the user's side the session simply stops responding.MALFORMED_RESPONSEis retryable). With the community patch applied, the identical request is replayed up to 5 times with exponential backoff (496 → 991 → 2161 → 4197 → 8729 ms), spending ~14 s and five full prompt resends (≈400k input tokens each in the case below) before failing the same way. A deterministic refusal fails 5/5; a coin-flip refusal occasionally passes on retry 4.Expected
A refusal is a terminal, well-formed outcome. The turn should end cleanly, the refusal should be surfaced as content (not as an error), and the user should be able to continue the session — exactly like
RATE_LIMIT/TIMEOUT.Actual
Observed across 4 sessions on one machine within 3 hours (1 primary + 3 follow-ups that reproduced it independently).
Stock behaviour (no bundle patch):
With the community retry patch applied:
retry=4occasionally returned a normal completion (assistant/messagewith a regular stop). This is why the symptom is intermittent rather than deterministic.Why this is not a context-length problem
All three ran the same build, same provider, same policy, window = 1,048,576 tokens. The largest session in the set never saw a refusal; the failing one is a quarter its size.
Root cause
refusal:MALFORMED_RESPONSEis treated as unrecoverable for UI purposes:Related public reports
[Bug] Benign Chinese ops prompt → stream ends with stop reason "refusal" → client reports MALFORMED_RESPONSE (deepseek-flash). Same mapping defect, reached from ordinary content.dsh-plugin.org/zh/tutorials/fix-refusal-malformed(2026-10-30) — same three-layer analysis; explicitly says only the client mapping half is documentable.dsh-llm-net-retry— ships a table mappingunknown stop_reason → MALFORMED_RESPONSE, i.e. the ecosystem works around this at plugin level.billion-contextPR 非electron类型的桌面端(Non-Electron desktop client) #2610 (commitba70cc1) — addsMALFORMED_RESPONSEto the retry whitelist; that is the source of the 5× replay on this machine.Suggested fixes
Minimum (one branch):
plus: render
kind: "refusal"as a normal turn end (message shown, no error banner, "continue" available).Independent, worth doing anyway:
MALFORMED_RESPONSEin the defaultretryableCodes. A protocol/parse mismatch is not transient; re-sending the same body is at best a coin flip and at worst five full prompt resends (~400k tokens each here).MALFORMED_RESPONSEa continuation path, or map refusals out of the error channel entirely, so a dead end has an exit.default: an unknown but syntactically valid stop reason should degrade to{ kind: "stop" }with a warning, not to a hard error. Today one new upstream stop reason can brick long sessions across the fleet.Secondary observation (different subsystem, not a blocker)
systemPromptUpdate: "in-history"appends a complete copy of the rendered system prompt whenever it changes by a single byte, and never removes superseded copies. In the affected session that produced 558 copies of a 53 KB prompt ≈ 29 MB of duplicated prompt text (measured from the session journal; request-side cost is the cached prefix, so this is storage and cache-prefix churn rather than per-token billing).Two compounding sources of churn, both local but both exploiting a core design choice:
// hang full prompt-inject every step).Either a
volatilemarker on aPromptSection, or compaction of superseded system nodes, would bound this. Reported separately from the refusal bug.Reproducibility
refusal→MALFORMED_RESPONSE→ turnerror.type: "llm/retry"records:data.failure.code,data.failure.message,data.retry,data.maxRetries,data.delayMs.Not claimed
refusal, or on what content should or should not be refused. The defect is purely the client's translation of a legal terminal state.All reactions