Repository navigation
llm-pi-ai Timeout increase for local LLMs #3157
Replies: 25 comments 15 replies
|
having the same issue as you , i tried settings.yaml too , didn't work i also tried to manually change it in llm-pi-ai/src/adapter.ts but still get a timeout |
|
Even after updating settings.yaml, the issue persists with a different error. Exactly at the 5-minute mark, the failure reason now changes from 'timeout' to 'terminated'. For context, I can run this exact same local LLM successfully without any timeout issues in OpenCode. |
|
The 5-minute cutoff is the pi-ai adapter default, not Ollama. llm-pi-ai:
providers:
ollama:
streamIdleTimeoutMs: 1200000
timeoutMs: 1200000Then check the composed tree with Patching If dump-config is already 20 minutes and the failure still flips to |
|
I have had exactly the same problem: first a timeout, and then when that was fixed a "terminated" error. In my case it was always failing while trying to write out the file whose contents it had worked out. The cause seems to be a timeout under Plugins->Plugin Configuration->Shell where there is a command timeout of 120s by default. This should be more than enough to write out a short code segment. But the time limit seems to be applied from the time when the agent starts to create the tool call - which with a local model can take a considerable amount of time. I have bumped up this limit to a very large number and so far this seems to have resolved the problem. One thing I hadn't realised was that in several cases, the harness had stopped the turn and then rerun it up to 5 times, stopping it each time it reached the point of writing the file but discarding all trace of the run that it killed. So it never left a usable log of exactly what was going on at the moment of failure. I am not sure whether these aborted turns are logged somewhere unobvious but it would help if it didn't completely erase all trace of them. EDIT: It hasn't fixed the problem. It has just failed again. But it is definitely somehow linked to the "write file" tool call taking a long time. |
|
@njcray2 Two clocks. The Shell plugin’s 120s timeout is measured from when the tool call is created, so a slow local model filling If it still dies at ~5:00 with |
|
Thanks, this explains why changing settings.yaml only changed the error from timeout to terminated for some people. |
|
@ylwl1997 I don't actually see any of the config in settings.yaml reflected in the output from --dump-config but they are being honoured. Your confirmation that the shell tool timing does include the time it takes the model to fill the arguments is very useful. I am going to check again in case I didn't restart a new session before. Ollama's server log reports that it received a "cancel task" and the time of the previous completion is often suspiciously close to 5m. So either I didn't correctly increase the shell command timeout or there is another 5m limit somewhere. All these failures occur during the write tool call though so it is definitely pointing at the requirement that the LLM must create the tool call within 5m. |
|
Hello everyone, I resolved this by adding a dispatcher that adjusts the timeout to match the adapter's timeout. Here are the changes: llm-pi-ai -> adapter.tsfunction profileOptions( openai-completions.jsimport { Agent, fetch } from "undici"; const dispatchers = new Map(); function dispatcherFor(timeoutMs) { if (dispatcher === undefined) { return dispatcher; const client = createClient( const requestOptions = { return new OpenAI({ Final changessettings.yaml |
|
Confirming the fix on macOS (M1 Max, LM Studio + llama.cpp backend, dsh 0.1.1-rc.2). One step is missing from the recipe above, and it is probably why some of us could not reproduce it: undici is not a dependency of dsh. The import throws ERR_MODULE_NOT_FOUND. Run "npm install undici" in the harness folder first. Also, patch the COMPILED file, not the sources, as ylwl1997 already noted: node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js A diagnostic that costs nothing, for anyone unsure whether they are hitting this rather than a backend timeout. If you have any proxy or relay between dsh and your model server, look at the request sizes it logs. The signature is the SAME byte size resent every five minutes: 23:15:28 120 493 bytes Identical size means a retry of the same request, not a conversation moving forward. That is the client giving up at 300 s, not the backend closing. Before and after on our side. Short turns always landed, long ones never did: answers under 400 tokens completed every time, answers over 2500 tokens died every time with "Failure reason: terminated", at exactly the 5:00 mark. After the patch, one turn ran 5 min 54 s and completed: 02:45:44 request sent, 101 381 bytes Different size, so the conversation moved on instead of retrying. That same turn wrote a 5.8 KB test file in a single tool call, which is precisely the gesture that died before. Worth stating for future readers: this patch lives in node_modules and is lost on every reinstall of dsh. An upstream fix, or a postinstall patch, would help a lot of local-model users. |
|
Hello again, have been following and attempting changes as suggested but
here on Win11 get many errors from code added to src/adapter.ts - It is
difficult for an amateur to understand and likely have placed code in wrong
place or was that the fix for linux or mac? Would really like to get this
sorted as I can see some potential.
@***@***.*** build:lib:host
tsc -b tsconfig.host.json && tsdown --env.DSH_BUILD_FACE host
packages/llm/llm-pi-ai/src/adapter.ts:99:3 - error TS18004: No value exists
in scope for the shorthand property 'maxRetries'. Either declare one or
provide an initializer.
99 maxRetries,
~~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:100:3 - error TS18004: No value
exists in scope for the shorthand property 'websocketConnectTimeoutMs'.
Either declare one or provide an initializer.
100 websocketConnectTimeoutMs,
~~~~~~~~~~~~~~~~~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:101:3 - error TS18004: No value
exists in scope for the shorthand property 'timeoutMs'. Either declare one
or provide an initializer.
101 timeoutMs,
~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:102:3 - error TS2552: Cannot find
name 'transport'. Did you mean 'WebTransport'?
102 transport,
~~~~~~~~~
***@***.***
/node_modules/typescript/lib/lib.dom.d.ts:41001:13
41001 declare var WebTransport: {
~~~~~~~~~~~~
'WebTransport' is declared here.
packages/llm/llm-pi-ai/src/adapter.ts:103:3 - error TS18004: No value
exists in scope for the shorthand property 'cacheRetention'. Either declare
one or provide an initializer.
103 cacheRetention,
~~~~~~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:104:3 - error TS18004: No value
exists in scope for the shorthand property 'thinkingBudgets'. Either
declare one or provide an initializer.
104 thinkingBudgets,
~~~~~~~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:113:1 - error TS2375: Type '{
maxRetries: number; websocketConnectTimeoutMs?: number; timeoutMs?: number;
transport?: Transport; cacheRetention?: CacheRetention; thinkingBudgets?:
ThinkingBudgets; reasoning?: ModelThinkingLevel | undefined; apiKey?:
string | undefined; }' is not assignable to type 'SimpleStreamOptions & {
streamIdleTimeoutMs: number; }' with 'exactOptionalPropertyTypes: true'.
Consider adding 'undefined' to the types of the target's properties.
Type '{ maxRetries: number; websocketConnectTimeoutMs?: number;
timeoutMs?: number; transport?: Transport; cacheRetention?: CacheRetention;
thinkingBudgets?: ThinkingBudgets; reasoning?: ModelThinkingLevel |
undefined; apiKey?: string | undefined; }' is not assignable to type
'SimpleStreamOptions' with 'exactOptionalPropertyTypes: true'. Consider
adding 'undefined' to the types of the target's properties.
Types of property 'reasoning' are incompatible.
Type 'ModelThinkingLevel | undefined' is not assignable to type
'ThinkingLevel'.
Type 'undefined' is not assignable to type 'ThinkingLevel'.
113 return {
~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:144:3 - error TS18004: No value
exists in scope for the shorthand property 'maxRetries'. Either declare one
or provide an initializer.
144 maxRetries,
~~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:148:5 - error TS2304: Cannot find
name 'websocketConnectTimeoutMs'.
148 if (websocketConnectTimeoutMs !== undefined)
options.websocketConnectTimeoutMs = websocketConnectTimeoutMs;
~~~~~~~~~~~~~~~~~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:148:82 - error TS2304: Cannot find
name 'websocketConnectTimeoutMs'.
148 if (websocketConnectTimeoutMs !== undefined)
options.websocketConnectTimeoutMs = websocketConnectTimeoutMs;
~~~~~~~~~~~~~~~~~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:149:5 - error TS2304: Cannot find
name 'timeoutMs'.
149 if (timeoutMs !== undefined) options.timeoutMs = timeoutMs;
~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:149:50 - error TS2304: Cannot find
name 'timeoutMs'.
149 if (timeoutMs !== undefined) options.timeoutMs = timeoutMs;
~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:150:5 - error TS2304: Cannot find
name 'transport'.
150 if (transport !== undefined) options.transport = transport;
~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:150:50 - error TS2304: Cannot find
name 'transport'.
150 if (transport !== undefined) options.transport = transport;
~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:151:5 - error TS2304: Cannot find
name 'cacheRetention'.
151 if (cacheRetention !== undefined) options.cacheRetention =
cacheRetention;
~~~~~~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:151:60 - error TS2304: Cannot find
name 'cacheRetention'.
151 if (cacheRetention !== undefined) options.cacheRetention =
cacheRetention;
~~~~~~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:152:5 - error TS2304: Cannot find
name 'thinkingBudgets'.
152 if (thinkingBudgets !== undefined) options.thinkingBudgets =
thinkingBudgets;
~~~~~~~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:152:62 - error TS2304: Cannot find
name 'thinkingBudgets'.
152 if (thinkingBudgets !== undefined) options.thinkingBudgets =
thinkingBudgets;
~~~~~~~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:153:5 - error TS2304: Cannot find
name 'apiKey'.
153 if (apiKey !== undefined) options.apiKey = apiKey;
~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:153:44 - error TS2304: Cannot find
name 'apiKey'.
153 if (apiKey !== undefined) options.apiKey = apiKey;
~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:156:5 - error TS2304: Cannot find
name 'reasoning'.
156 if (reasoning && reasoning !== 'off') {
~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:156:18 - error TS2304: Cannot find
name 'reasoning'.
156 if (reasoning && reasoning !== 'off') {
~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:157:23 - error TS2304: Cannot find
name 'reasoning'.
157 options.reasoning = reasoning;
~~~~~~~~~
packages/llm/llm-pi-ai/src/adapter.ts:160:1 - error TS1108: A 'return'
statement can only be used within a function body.
160 return options as SimpleStreamOptions & { streamIdleTimeoutMs: number };
~~~~~~
Found 24 errors.
[ELIFECYCLE] Command failed with exit code 2.
PS C:\users\user\deepseek-harness>
…On Mon, Aug 24, 2026 at 8:44 PM Mcbest06 ***@***.***> wrote:
Hello everyone,
I had the same problem.
It stems from the dynamic Undici HTTP Dispatcher layer, which has a
timeout of 300,000ms.
So, whenever the configured timeout exceeds that limit, the connection
cuts off with the error: "Failure reason: terminated"
I resolved this by adding a dispatcher that adjusts the timeout to match
the adapter's timeout.
Here are the changes:
llm-pi-ai -> adapter.ts
function profileOptions(
profile: ResolvedPiAiProviderProfile,
reasoning: ModelThinkingLevel | undefined,
apiKey: string | undefined,
): SimpleStreamOptions & { streamIdleTimeoutMs: number } {
return {
...apiKey === undefined ? {} : { apiKey },
...profile.timeoutMs === undefined ? {} : { timeoutMs: profile.timeoutMs },
streamIdleTimeoutMs: profile.streamIdleTimeoutMs,
maxRetries: 0,
}
}
openai-completions.js
import { Agent, fetch } from "undici";
const dispatchers = new Map();
function dispatcherFor(timeoutMs) {
let dispatcher = dispatchers.get(timeoutMs);
if (dispatcher === undefined) {
dispatcher = new Agent({
bodyTimeout: timeoutMs,
headersTimeout: timeoutMs,
});
dispatchers.set(timeoutMs, dispatcher);
}
return dispatcher;
}
const client = createClient(
model,
context,
apiKey,
options?.headers,
cacheSessionId,
compat,
options?.streamIdleTimeoutMs,
);
const requestOptions = {
...(options?.signal ? { signal: options.signal } : {}),
timeout: options?.streamIdleTimeoutMs,
maxRetries: 0,
};
return new OpenAI({
apiKey,
baseURL: model.baseUrl,
dangerouslyAllowBrowser: true,
defaultHeaders: headers,
...(streamIdleTimeoutMs === undefined
? {}
: {
fetch: (input, init) => fetch(input, {
...init,
dispatcher: dispatcherFor(streamIdleTimeoutMs),
}),
}),
});
Final changes
settings.yaml
→ profile.streamIdleTimeoutMs
→ dsh-llm-pi-ai profileOptions()
→ pi-ai streamSimple()
→ buildBaseOptions()
→ openai-completions.stream()
→ timeout OpenAI SDK
→ dispatcher Undici bodyTimeout / headersTimeout
→ requête HTTP To Ollama/LM Studio...
—
Reply to this email directly, view it on GitHub
<#3157?email_source=notifications&email_token=AGEDREIZBYY4D5NNG3WKXEL5LQ2DXA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOBRGM2DSNRQUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVRTG633UMVZF6Y3MNFRWW#discussioncomment-18134960>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGEDREJ3JATQWL52W75YNTT5LQ2DXAVCNFSNUABJKJSXA33TNF2G64TZHMYTGMZTGA3DKMBZGE5UI2LTMN2XG43JN5XDWMJQGY2DAMJYGOQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AGEDRENPIARTJIGAZVVIMGT5LQ2DXA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOBRGM2DSNRQUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVJTG633UMVZF62LPOM>
and Android
<https://github.com/notifications/mobile/android/AGEDREMRN57Y7ASDGFRCATT5LQ2DXA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOBRGM2DSNRQUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVZTG633UMVZF6YLOMRZG62LE>.
Download it today!
You are receiving this because you authored the thread.Message ID:
<deepseek-ai/deepseek-harness/repo-discussions/3157/comments/18134960@
github.com>
--
*Kununurra Historical Society* Inc. (*Est. 1986*)
Archive, Library, Museum & Research
72 Coolibah Drive near the corner of Messmate Way (100m from the PO)
PO Box 77 KUNUNURRA WA 6743 - Phone: +61 (0) 8 9169 3331
*http://www.kununurra.org.au/ <http://www.kununurra.org.au/>*
*Please update your contacts as this REPLY is from an old email address.The
address on this eMail will remain - However we
prefer... ***@***.*** ***@***.***>*
If you do not wish to receive emails reply and change *subject* to "REMOVE"
|
|
Hello again,
I tried the patch but on Win11 (Ollama local models) get PS
C:\users\user\deepseek-harness> git apply --check
***@***.******@***.***
error: corrupt patch at line 92 - Tried adding the "+" to streamIdleTimeoutMs?:
number; but no matter what I have tried to a re-cloned clean repo still
get error since first trying. TIA for any assistance
AB
…On Wed, Aug 26, 2026 at 4:37 AM njcray2 ***@***.***> wrote:
Just an fyi: there seems to be an error in the patch.
Clearly
/**
+ * Stream idle timeout in milliseconds for providers that support
+ * long-lived streaming transports.
+ *
+ */
streamIdleTimeoutMs?: number;
should be applying the edit to the whole comment and extra option:
+ /**
+ * Stream idle timeout in milliseconds for providers that support
+ * long-lived streaming transports.
+ *
+ */
+ streamIdleTimeoutMs?: number;
The line numbers for this edit are not right either. I ended up doing this
part of the patch by hand. However apart from that, the fix is working.
—
Reply to this email directly, view it on GitHub
<#3157?email_source=notifications&email_token=AGEDREKE5GKAPJUFD4EOCOD5LX2IRA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOBRGUZTIMZTUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVRTG633UMVZF6Y3MNFRWW#discussioncomment-18153433>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGEDREIDTZO3QJHL7LPO4X35LX2IRAVCNFSNUABJKJSXA33TNF2G64TZHMYTGMZTGA3DKMBZGE5UI2LTMN2XG43JN5XDWMJQGY2DAMJYGOQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AGEDREKY7T7EJUXDXRIS25L5LX2IRA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOBRGUZTIMZTUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVJTG633UMVZF62LPOM>
and Android
<https://github.com/notifications/mobile/android/AGEDRENCOJC6DC2SZ4DGWPT5LX2IRA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOBRGUZTIMZTUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVZTG633UMVZF6YLOMRZG62LE>.
Download it today!
You are receiving this because you authored the thread.Message ID:
<deepseek-ai/deepseek-harness/repo-discussions/3157/comments/18153433@
github.com>
--
*Kununurra Historical Society* Inc. (*Est. 1986*)
Archive, Library, Museum & Research
72 Coolibah Drive near the corner of Messmate Way (100m from the PO)
PO Box 77 KUNUNURRA WA 6743 - Phone: +61 (0) 8 9169 3331
*http://www.kununurra.org.au/ <http://www.kununurra.org.au/>*
*Please update your contacts as this REPLY is from an old email address.The
address on this eMail will remain - However we
prefer... ***@***.*** ***@***.***>*
If you do not wish to receive emails reply and change *subject* to "REMOVE"
|
|
following up in case anyone else is still running into this with llama.cpp. I ran into two separate problems and neither needed a source or node_modules fix:
|
Fixed without touching any source code: the hidden 5-minute killer is undici's dispatcher defaults
Same symptoms as this thread: turns die at ~5:00 even after Root causeIn the dsh process, LLM streaming ends at Node's built-in
So with Confirmed with a local probe: a stream emitting one small chunk every 3 s is aborted with The fix: one preload module + one env var, zero source changesSave this as // dsh-undici-fix.mjs — raise undici's streaming timeout defaults for this process
const MAX_MS = 2_147_483_647 // 2**31-1 ms ≈ 24.85 days = Node's safe max for timers
async function loadUndici() {
try { const m = await import('undici'); if (m.Agent) return m } catch {}
// fallback: resolve from the DSH checkout's pnpm store (same undici the SDK resolves)
const cands = [
'/home/USER/deepseek-harness/node_modules/.pnpm/undici@7.28.0/node_modules/undici/index.js',
]
for (const p of cands) {
try { const m = await import(new URL(`file://${p}`).href); if (m.Agent) return m } catch {}
}
throw new Error('dsh-undici-fix: cannot resolve undici; run from the dsh environment or add undici to it')
}
const { Agent } = await loadUndici()
const FIXED = Symbol.for('dsh.undiciFix')
if (globalThis.fetch && !globalThis.fetch[FIXED]) {
const agent = new Agent({
bodyTimeout: MAX_MS, // per-chunk idle cap (default 300_000 = the 5-min killer)
headersTimeout: MAX_MS, // time-to-first-byte (default 300_000)
})
const original = globalThis.fetch
globalThis.fetch = (input, init) => original(input, { ...init, dispatcher: agent })
try { Object.defineProperty(globalThis.fetch, FIXED, { value: true }) } catch {}
}
console.error(`[dsh-undici-fix] bodyTimeout/headersTimeout raised to ${MAX_MS}ms (was 300_000ms)`);Then launch dsh with: export NODE_OPTIONS="--import /path/to/dsh-undici-fix.mjs"
dsh web # however you normally start it; the [dsh-undici-fix] line in stderr = activeAnd for consistency, also max the DSH-side knobs in llm-pi-ai:
providers:
<your-active-route>:
timeoutMs: 2147483647
streamIdleTimeoutMs: 2147483647Why this approach beats patching code (the part I'd push for upstream)
Caveats
Verified working: dsh (Node 26) → And because the whole fix is one self-contained module + one env var — diagnose, write, test, apply, verify, all in the same session, by the harness agent about to make far longer calls with it. |
|
I have tried all of the patches in this thread without success on Win11
and this one appeared to work (as per shell copy below) Thanks for adding
this and have eventually figured out how to get it going on Win11, however
I am now getting 2 x 5 min Timeouts, BOTH within seconds of sending a
prompt - So now just dies within seconds, models never get a chance, so
stuck again with DSH (for local LLMs)? TIA to anyone with any ideas to fix?
One thing I have noticed is that the error message has changed from
"Failure reason: Request timed out." to Failure reason: "Connection
error.", as below.
Retried model request (2/2) 1s
Retry delay: 938ms
Failure reason: "Connection error." [New?]
[WAS - "Failure reason: Request timed out."]
The only change I made when it did not work at first was a change to line
13
// FROM: throw new Error('dsh-undici-fix: cannot resolve undici...') TO
const undici = await import('undici');
>>>>>>>>>>>>>
[Install undici Win11
PS C:\Windows\system32> cd C:\users\user
PS C:\users\user> cd deepseek-harness
PS C:\users\user\deepseek-harness> pnpm add -w undici
native/landlock-run/packages/linux-arm64 | [WARN] Unsupported platform:
wanted: {"cpu":["arm64"],"os":["linux"],"libc":["any"]} (current:
{"os":"win32","cpu":"x64","libc":"unknown"})
native/landlock-run/packages/linux-x64 | [WARN] Unsupported platform:
wanted: {"cpu":["x64"],"os":["linux"],"libc":["any"]} (current:
{"os":"win32","cpu":"x64","libc":"unknown"})
✓ Lockfile passes supply-chain policies (verified 14d ago)
╭──────────────────────────────────────────╮
│ │
│ Update available! 11.7.0 → 11.25.0. │
│ Changelog: https://pnpm.io/v/11.25.0 │
│ To update, run: pnpm add -g pnpm │
│ │
╰──────────────────────────────────────────╯
[WARN] 4 deprecated subdependencies found: ***@***.***, ***@***.***,
***@***.***, ***@***.***
Progress: resolved 1204, reused 0, downloaded 0, added 0, done
dependencies:
+ undici ^8.10.1
Packages: +1
+
. postinstall$ node scripts/install-lefthook.mjs
│ sync hooks: ✔️(pre-merge-commit, pre-commit, pre-push)
│ (node:10912) [DEP0190] DeprecationWarning: Passing args to a child
process with shell option true can lead to security vulnerabilities, as the
arguments are not escaped,…
│ (Use `node --trace-deprecation ...` to show where the warning was created)
└─ Done in 3.2s
Done in 34.3s using pnpm v11.7.0
PS C:\users\user\deepseek-harness> $env:NODE_OPTIONS="--import
file:///C:/Users/User/deepseek-harness/patches/Undici-Fix/dsh-undici-fix.mjs"
PS C:\users\user\deepseek-harness> pnpm dsh web
[dsh-undici-fix] bodyTimeout/headersTimeout raised to 2147483647ms (was
300_000ms)
[dsh-undici-fix] bodyTimeout/headersTimeout raised to 2147483647ms (was
300_000ms)
$ node --import tsx/esm apps/cli/src/bin.ts "web"
[dsh-undici-fix] bodyTimeout/headersTimeout raised to 2147483647ms (was
300_000ms)
dsh web: http://127.0.0.1:3080
On Wed, Sep 2, 2026 at 11:53 AM Airlian Her ***@***.***> wrote:
Fixed without touching any source code: the hidden 5-minute killer is
undici's dispatcher defaults
*Provenance:* this write-up was produced by a *DeepSeek Harness agent
fixing its own environment*. The agent was the one suffering from the
~5-minute aborts (its own model calls were being killed). On the user's
request it:
1. *read this thread first* — including the attempts that didn't work
(patching adapter.ts in a git checkout while dsh runs from the
published package) and the one that did (the undici dispatcher) — instead
of re-deriving everything from scratch;
2. *then independently dug into the actual code path on its own
machine*, layer by layer: DSH's llm-pi-ai profile schema (
streamIdleTimeoutMs capped at MAX_TIMER_DELAY_MS, enforced by a
setTimeout-based watchdog) → pi-ai's openai-completions client
construction (only a per-request timeout option reaches the OpenAI
SDK; the client itself gets none) → the OpenAI SDK's fetchWithTimeout
(a total-deadline setTimeout) → and finally Node's built-in
globalThis.fetch = *undici*, whose dispatcher keeps two fixed *300 000
ms* defaults (headersTimeout, bodyTimeout) that none of the layers
above or below can configure;
3. *wrote the preload module and a local streaming probe* (small
bodyTimeout → reproducible UND_ERR_BODY_TIMEOUT; large → survival) and
verified them before handing back the fix.
In short: informed by this thread, but each link confirmed against the
real sources in the running environment — and the agent *self-repaired
its own runtime* with zero edits to DSH, pi-ai, or the SDK.
Same symptoms as this thread: turns die at ~5:00 even after timeoutMs /
streamIdleTimeoutMs are set to 2h in settings.yaml; the error flips from
timeout to terminated; the stream *already produced the first token*
before it dies; long/new prompts (that the model can't short-cut) are hit
hardest.
Root cause
In the dsh process, LLM streaming ends at Node's built-in globalThis.fetch
— i.e. *undici*. Its dispatcher has two *300 000 ms (5 min) defaults that
no DSH setting controls*:
- headersTimeout — how long to wait for the *first* response
byte/token (kills turns where a long new prompt takes >5 min to start
generating),
- bodyTimeout — the idle window *between chunks*; it resets on every
chunk received (kills turns mid-stream after the first token).
So with timeoutMs: 7200000 + streamIdleTimeoutMs: 7200000 configured,
*any* silent 5-minute interval — model "thinking" on an unprocessed long
prompt, or gateway buffering — still aborts the stream, from *below*
every timeout DSH exposes. This also explains the "5 / 8 / 9 minutes"
spread: it is not wall-clock 5 minutes, it's a 5-minute *idle window*
landing wherever the gap occurs (before the first token, or mid-stream).
Confirmed with a local probe: a stream emitting one small chunk every 3 s
is aborted with UND_ERR_BODY_TIMEOUT when bodyTimeout=2000 is forced, and
survives with bodyTimeout=2**31-1. The killer is exactly this timer — and
Node's built-in fetch honors a userland undici dispatcher passed in init.
The fix: one preload module + one env var, zero source changes
Save this as dsh-undici-fix.mjs (works as-is; the fallback path is for
pnpm layouts like the DSH monorepo):
// dsh-undici-fix.mjs — raise undici's streaming timeout defaults for this processconst MAX_MS = 2_147_483_647 // 2**31-1 ms ≈ 24.85 days = Node's safe max for timers
async function loadUndici() {
try { const m = await import('undici'); if (m.Agent) return m } catch {}
// fallback: resolve from the DSH checkout's pnpm store (same undici the SDK resolves)
const cands = [
***@***.***/node_modules/undici/index.js',
]
for (const p of cands) {
try { const m = await import(new URL(`file://${p}`).href); if (m.Agent) return m } catch {}
}
throw new Error('dsh-undici-fix: cannot resolve undici; run from the dsh environment or add undici to it')}
const { Agent } = await loadUndici()const FIXED = Symbol.for('dsh.undiciFix')if (globalThis.fetch && !globalThis.fetch[FIXED]) {
const agent = new Agent({
bodyTimeout: MAX_MS, // per-chunk idle cap (default 300_000 = the 5-min killer)
headersTimeout: MAX_MS, // time-to-first-byte (default 300_000)
})
const original = globalThis.fetch
globalThis.fetch = (input, init) => original(input, { ...init, dispatcher: agent })
try { Object.defineProperty(globalThis.fetch, FIXED, { value: true }) } catch {}}console.error(`[dsh-undici-fix] bodyTimeout/headersTimeout raised to ${MAX_MS}ms (was 300_000ms)`);
Then launch dsh with:
export NODE_OPTIONS="--import /path/to/dsh-undici-fix.mjs"
dsh web # however you normally start it; the [dsh-undici-fix] line in stderr = active
And for consistency, also max the DSH-side knobs in settings.yaml (2³¹−1
≈ 24.85 days is the practical max — Node's setTimeout clamps anything
larger to 1 ms, which would be a *shorter* timeout):
llm-pi-ai:
providers:
<your-active-route>:
timeoutMs: 2147483647
streamIdleTimeoutMs: 2147483647
Why this approach beats patching code (the part I'd push for upstream)
1. *No source at all.* No pi-ai dist edit, no adapter.ts patch (the
attempts in this thread that "did nothing"), no rebuild. Patching the git
checkout is pointless when dsh runs from the published package (npx / npm
i -g); this reaches the *actual running process*, so it works no
matter how dsh was installed.
2. *One interception point, every path fixed.* The hook sits at
process-global fetch, so every provider route (openai-completions,
openai-responses, anthropic-messages, anything added later) — plus any
other long-horizon HTTP stream in the harness — gets healthy streaming
limits at once. Patching one API file fixes one file.
3. *Survives upgrades.* pnpm install / pi-ai version bumps cannot
erase it; it lives outside the dependency tree and is two lines of
environment to remove.
4. *Surgical & reversible.* It raises only the two *streaming* timers
(headers/body); connect timeout, keep-alive, pool behavior stay at
defaults. Unset NODE_OPTIONS and you're bit-for-bit back to stock.
5. *Self-contained & verifiable.* Startup logs one line; the mechanism
is independently provable with a 10-line local server test (small
bodyTimeout → UND_ERR_BODY_TIMEOUT; large → stream survives).
Caveats
- Restart the dsh process after setting the env var (hot-reload of
settings.yaml does not apply to a process-level change).
- Don't exceed 2³¹−1 ms anywhere — Node clamps larger setTimeout
delays to 1 ms (silent instant timeout).
- If long-idle deaths persist anyway, the remaining suspect is the
*remote* gateway/model server's own idle timeout (check its logs:
new-api / Ollama "cancel task", proxy proxy_read_timeout, etc.) —
that's outside the client.
- If your turn dies *during a tool call* (Shell / write arguments)
rather than model streaming, that's a different clock (plugin/tool time
budget) — bump that setting in addition.
Verified working: dsh (Node 26) → llm-pi-ai route on an OpenAI-compatible
gateway — streams that previously died at ~5 min (after the first token,
even) now run far beyond.
*And because the whole fix is one self-contained module + one env var —
diagnose, write, test, apply, verify, all in the same session, by the
harness agent about to make far longer calls with it.*
—
Reply to this email directly, view it on GitHub
<#3157?email_source=notifications&email_token=AGEDREMB3GA3BKKNUWVUPIT5M6KRZA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOBSGQZTENBZUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVRTG633UMVZF6Y3MNFRWW#discussioncomment-18243249>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGEDRENGMKVARSTKUX5ZTB35M6KRZAVCNFSNUABJKJSXA33TNF2G64TZHMYTGMZTGA3DKMBZGE5UI2LTMN2XG43JN5XDWMJQGY2DAMJYGOQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AGEDREK7EBTPDQEVPMVLYAT5M6KRZA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOBSGQZTENBZUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVJTG633UMVZF62LPOM>
and Android
<https://github.com/notifications/mobile/android/AGEDREO42KN64YFGDCPJ7MT5M6KRZA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOBSGQZTENBZUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVZTG633UMVZF6YLOMRZG62LE>.
Download it today!
You are receiving this because you authored the thread.Message ID:
<deepseek-ai/deepseek-harness/repo-discussions/3157/comments/18243249@
github.com>
--
*Kununurra Historical Society* Inc. (*Est. 1986*)
Archive, Library, Museum & Research
*http://www.kununurra.org.au/ <http://www.kununurra.org.au/>*
|
|
I moved the base url and timeouts close to top of settings.yaml and in a
new session seems to be working ok after re-loading and re-saving the 4
available models, and is working again but should I still be getting the
"Retried model request (2/2)" even though model goes well past ten
minutes, so guess it is working even though those timeout errors appear
maybe they mean nothing now OR should they have disappeared with the
patch?. TIA
…On Thu, Sep 3, 2026 at 10:22 PM njcray2 ***@***.***> wrote:
"Connection Error" sounds like something has got corrupted during the
editing. It is isn't even setting up the link. First easy thing to check is
that your settings.yaml is good -- especially correct indentation for the
new parameters for your provider.
—
Reply to this email directly, view it on GitHub
<#3157?email_source=notifications&email_token=AGEDREMDUGIWTHLIEEN7S2T5NF5DFA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOBSG4YDCNJYUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVRTG633UMVZF6Y3MNFRWW#discussioncomment-18270158>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGEDREOG3VS27Z7P53G2V7L5NF5DFAVCNFSNUABJKJSXA33TNF2G64TZHMYTGMZTGA3DKMBZGE5UI2LTMN2XG43JN5XDWMJQGY2DAMJYGOQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AGEDREMEK5PKACFUQXFKOJT5NF5DFA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOBSG4YDCNJYUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVJTG633UMVZF62LPOM>
and Android
<https://github.com/notifications/mobile/android/AGEDRELFZ44CQHTX5WTSDRT5NF5DFA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOBSG4YDCNJYUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVZTG633UMVZF6YLOMRZG62LE>.
Download it today!
You are receiving this because you authored the thread.Message ID:
<deepseek-ai/deepseek-harness/repo-discussions/3157/comments/18270158@
github.com>
--
|
|
Thanks for this as the original linux script did not work for Win11 (It
seemed to load BUT looked for models at "127.0.0.1/v1/models" even though
base url 127.0.0.1/v1 " no models? - so had access to no models) - Have
loaded and yes I have access to models again and has gone longer than 10
minutes BUT I wonder if you still get the 2 x 5 minute Retried model
request? No matter what I have tried I still see them and wonder if that is
the same for you, IE they appear but have no effect OR do they no longer
appear?
TIA
AB
…On Sat, Sep 5, 2026 at 3:35 PM cat-inGlasses ***@***.***> wrote:
Thank you.
It worked for me as well, but with some fxes.
I've had to download undici separately near that file
and also Claude rewrite this file to:
// dsh-undici-fix.mjs — raise undici's streaming timeout defaults for this process
const MAX_MS = 2_147_483_647 // 2**31-1 ms ≈ 24.85 days = Node's safe max for timers
const { fetch: undiciFetch, Agent } = await import('undici')
const agent = new Agent({
bodyTimeout: MAX_MS, // per-chunk idle cap (Node's native default: 300_000ms)
headersTimeout: MAX_MS, // time-to-first-byte (Node's native default: 300_000ms)
})
const FIXED = Symbol.for('dsh.undiciFix')
if (!globalThis.fetch?.[FIXED]) {
// IMPORTANT: pair this dispatcher only with THIS undici's own fetch —
// never with Node's native fetch, which is a separate undici instance
// and rejects/mismatches a foreign dispatcher.
const patched = (input, init) => undiciFetch(input, { ...init, dispatcher: agent })
try { Object.defineProperty(patched, FIXED, { value: true }) } catch {}
globalThis.fetch = patched
}
console.error(`[dsh-undici-fix] bodyTimeout/headersTimeout raised to ${MAX_MS}ms (was 300_000ms) — using undici's own fetch end-to-end`)
—
Reply to this email directly, view it on GitHub
<#3157?email_source=notifications&email_token=AGEDREIO2MGDDTBKCYWXSLT5NO65DA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOBTGAYTGMRVUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVRTG633UMVZF6Y3MNFRWW#discussioncomment-18301325>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGEDRELY4N7NYLVL6UUNKA35NO65DAVCNFSNUABJKJSXA33TNF2G64TZHMYTGMZTGA3DKMBZGE5UI2LTMN2XG43JN5XDWMJQGY2DAMJYGOQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AGEDREPWMRGBHY6R3SL5GOL5NO65DA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOBTGAYTGMRVUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVJTG633UMVZF62LPOM>
and Android
<https://github.com/notifications/mobile/android/AGEDRELCLIOJBNDRAUI2URT5NO65DA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOBTGAYTGMRVUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVZTG633UMVZF6YLOMRZG62LE>.
Download it today!
You are receiving this because you authored the thread.Message ID:
<deepseek-ai/deepseek-harness/repo-discussions/3157/comments/18301325@
github.com>
--
|
|
I am not seeing any retried errors now. What is the reason given when you click on the retried error? Does it eventually succeed? |
|
this bug is still around with latest version of dhs? |
|
Repro + root cause + verified workaround for the 5-minute Reproduced this on dsh 0.1.5-rc.1, Node 24, local Qwen 3.8 27B Q8_0 via Root cause — two gates, one silent amplifier:
Why diagnosis took a day (observability gap): the failure surfaced as Verified workarounds:
Proposal: native |
|
Problem still present in latest 0.2.1-alpha 2 and breaks processing of most tasks. Several sessions literally ruined by this timeout number. In llama.cpp Terminal i see how model task progress number below 1.00 but it received a task cancellation already. |
|
My recent: No solution works or helps with timeouts. solution by allend2092 - installed, not working |
|
This issue still occurs |
|
Hello, I checked current master because this keeps coming back. For a local llama.cpp server there are still two separate 5 minute gates, and they need different fixes.
Also good to know: The real cost under all this is the cold prefill itself, like the 213k tokens taking about 4.5 min. Keeping the head of the prompt stable and giving llama-server more |
|
I'm not sure why you still have this problem, but the patch i've posted above works perfectly in my DSH. Moreover i tested it on 3 different freshly installed distro and patch working, removing all timeouts. echo "${DSH_HOME:-$HOME/.dsh}" # check the data directory
tar -czf "$HOME/dsh-transfer.tar.gz" -C "$HOME" .dshTransfer On the clean computer: install DeepSeek Harness, close it, then restore the archive: [ ! -d "$HOME/.dsh" ] || mv "$HOME/.dsh" "$HOME/.dsh.before-transfer"
tar -xzf "$HOME/dsh-transfer.tar.gz" -C "$HOME"Launch Harness and check that your sessions and plugins appear. If a session refers to a project folder from the old computer, copy that project too or put it at the same path. Since Harness is still in preview and changes can affect compatibility, use the same Harness version on both computers for the first launch. |

Uh oh!
There was an error while loading. Please reload this page.
Hello anybody interested, after great successful start with Ollama Gemma4:12b on Win11, found any longer prompts end up with a 300,000 millisecond (5min) timeout - I'd like to get a 20 minute timeout in there for local LLMs but how? Tried adding a line in settings.yaml but no or got it wrong?
All reactions