You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a794c70
Browse filesBrowse the repository at this point in the historyBrowse files
opencode: drop chunkTimeout, add root pyrightconfig for LSP-payload fix
The chunkTimeout: 20000 setting added in b084e0f turns out to be
counter-productive: anomalyco/opencode#20466 documents that SSE-chunk
timeout errors hit a non-retryable code path in retry.ts, so the
setting converted silent multi-minute hangs into hard failures with no
SDK retry. Removed from overlay, docs, and bats; bats now asserts the
key is absent. Live config required one-time manual jq del because
modify_ overlays can only add/overwrite, not delete.
Add pyrightconfig.json at the repo root to suppress Pyright LSP noise
from PEP 723 inline-script-deps Python files (scripts/, dot_ansible/).
Per anomalyco/opencode#17578 these diagnostics get appended to tool
responses and inflate the SSE payload, aggravating the same Copilot
proxy idle-timeout stall. Excluded via .chezmoiignore.tmpl so it stays
git-tracked but never deployed to $HOME.
Rewrite docs/tools/opencode.md mitigation section to cite the upstream
issues (#17578, #17574, #17307, #17318, #17336, #20466, #21173),
explain the LSP-payload aggravator, and expand the when-to-revisit
list to cover four distinct upstream-fix scenarios.
@@ -55,8 +55,7 @@ The `modify_` overlay model deep-merges only the keys we explicitly enforce; eve
55
55
-`default_agent = "build"` — primary agent on TUI/CLI startup. Override per-session via `--agent` or the picker.
56
56
-`small_model = "github-copilot/gpt-5-mini"` — cheap model for title generation, summarisation, and other lightweight calls. Avoids billing Claude Opus quota for trivial tasks. Pairs with `agent.title.reasoningEffort = "low"`.
57
57
-`agent.title.reasoningEffort = "low"` — cheap completions for short title generation; sibling `agent.*` entries (per-agent provider, model overrides) survive.
58
-
-`provider.github-copilot.options.timeout = 600000` (10 min) — request-level timeout. Default is 5 min; bumped to give long Claude Opus generations more room before the SDK aborts the whole call.
59
-
-`provider.github-copilot.options.chunkTimeout = 20000` (20 s) — abort an in-flight stream if no SSE chunk arrives for 20 s. Counter-intuitive but **this is the fix for the "Tool execution aborted" loop on Copilot's Claude Opus channel**: the Copilot proxy occasionally stalls a stream past its own ~60 s server-side idle window, after which the connection silently dies. With no `chunkTimeout` set, the SDK waits the full request `timeout` for a chunk that will never come; with 20 s the SDK cancels and retries early, getting unstuck in seconds instead of minutes. See [docs/tools/opencode.md](opencode.md#claude-opus-stream-stall-on-github-copilot) for the diagnosis from log evidence.
58
+
-`provider.github-copilot.options.timeout = 600000` (10 min) — request-level timeout. Default is 5 min; bumped to give long Claude Opus generations more room before the SDK aborts the whole call. **Note**: `chunkTimeout` is intentionally NOT set here, see [docs/tools/opencode.md → Claude Opus stream stall](opencode.md#claude-opus-stream-stall-on-github-copilot) for the rationale (upstream bug [anomalyco/opencode#20466](https://github.com/anomalyco/opencode/issues/20466) — SSE-chunk-timeout errors aren't retried, so setting `chunkTimeout` would convert silent hangs into hard failures with no recovery).
Copy file name to clipboardExpand all lines: docs/tools/opencode.md
+26-12Lines changed: 26 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,7 +72,14 @@ When using the `github-copilot/claude-opus-4.x` channel for long-running tool ca
72
72
73
73
GitHub Copilot's proxy in front of the Anthropic upstream enforces an idle timeout (community-observed at ~60 s) on streaming responses. Claude Opus generating a very large single tool-call payload can stay below the chunk emission threshold long enough to trip this, after which the connection silently dies. Direct Anthropic API does not have this behaviour. Sonnet trips it less often than Opus because it generates faster.
74
74
75
-
There is **no client-side flag to disable the proxy's idle timeout** — it's enforced server-side. The two viable mitigations are: (1) cancel-and-retry early so the SDK isn't blocked the full request timeout waiting for chunks that will never arrive, and (2) avoid emitting one giant tool call in the first place.
75
+
There is **no client-side flag to disable the proxy's idle timeout** — it's enforced server-side.
76
+
77
+
### Upstream tracking
78
+
79
+
-[anomalyco/opencode#17578](https://github.com/anomalyco/opencode/issues/17578) — exact symptom match: `Write tool SSE timeout with claude-opus-4.x via GitHub Copilot when generating long markdown files`. Reporter found that **Pyright LSP diagnostics get appended to tool responses** and inflate the SSE payload, making the stall more likely. Even writing a `.md` file can trigger a full project re-scan in repos containing Python sources without a configured venv. Fix in PR `#18894` (not merged at time of writing).
80
+
-[anomalyco/opencode#17574](https://github.com/anomalyco/opencode/issues/17574), [#17307](https://github.com/anomalyco/opencode/issues/17307), [#17318](https://github.com/anomalyco/opencode/issues/17318), [#17336](https://github.com/anomalyco/opencode/issues/17336) — additional reports of the same SSE-stall pattern; `#17307` is the original issue under which `chunkTimeout` was added as a stop-gap.
81
+
-[anomalyco/opencode#20466](https://github.com/anomalyco/opencode/issues/20466) — **`chunkTimeout` does not actually retry**: when the chunk-timeout fires, the resulting `SSE read timed out` error is wrapped as `NamedError.Unknown` and the `retryable()` predicate in `retry.ts` rejects it (fails the `JSON.parse()` branch). Net effect: setting `chunkTimeout` converts a silent multi-minute hang into a hard failure with **no automatic retry**, which is often worse UX than leaving it unset and relying on the SDK's request-level retry. Fix in PRs `#21727` and `#23501` (neither merged).
82
+
-[anomalyco/opencode#21173](https://github.com/anomalyco/opencode/issues/21173) — analogous problem on the OpenAI Responses provider (different transport, same shape).
-`chunkTimeout: 20000` cancels a stalled stream after 20 s of silence and lets the SDK reconnect, instead of waiting the full request `timeout`.
92
-
-`timeout: 600000` (10 min) extends the request-level cap so legitimately long generations aren't aborted prematurely after the first reconnect succeeds.
98
+
-`timeout: 600000` (10 min) extends the request-level cap so legitimately long generations aren't aborted prematurely.
99
+
-**`chunkTimeout` is intentionally NOT set.** A previous version of this overlay set `chunkTimeout: 20000` on the assumption that early cancel-and-retry would unstick the stream faster than waiting the full request timeout. Live testing on this machine showed the setting fires correctly (`SSE read timed out` at ~20 s, visible in `~/.local/share/opencode/log/2026-04-22T105313.log` lines 183, 257) but the error is **not retried** because of upstream bug `#20466` — `retryable()` in `retry.ts` rejects the error class. Net result was "20 s hang then hard fail with no recovery", which is worse than "silent hang then SDK request-level retry". Removed pending one of the linked PRs landing.
100
+
101
+
### LSP-payload aggravator (Action 3 — managed at repo root)
93
102
94
-
This shrinks the visible "stuck" window from ~minutes to ~tens of seconds and lets retries actually make progress instead of hitting the same dead connection.
103
+
Per `#17578` the SSE payload includes diagnostics from any LSP server OpenCode auto-spawns for files in the working tree. In a chezmoi-managed dotfiles repo with stray Python scripts using PEP 723 inline-script-deps (`#!/usr/bin/env -S uv run --script`), Pyright cannot resolve the inline-declared dependencies and emits dozens of `reportMissingImports` diagnostics per file, which then ride along on every tool response. To suppress this noise the chezmoi repo root carries a [`pyrightconfig.json`](../../pyrightconfig.json) that:
104
+
105
+
- excludes ansible role trees, chezmoi source dirs (`dot_*/`), agent transcript dirs (`.specstory/`, `.claude/`, `.cursor/`, `.opencode/`), and `backups/`,
106
+
- sets `reportMissingImports = "none"` so PEP 723 scripts stop polluting the diagnostics channel.
107
+
108
+
This file lives at the repo root (not under any `dot_*/` source path) so it is part of the chezmoi git repo but never deployed to `$HOME`.
95
109
96
110
### Behavioural mitigation (not managed)
97
111
98
112
If a generation is still failing repeatedly, prompt the agent to:
99
113
100
114
1. write a minimal skeleton first via a small `write`,
101
-
2. fill each section incrementally via multiple `edit` calls.
102
-
103
-
This avoids the giant single-tool-call payload that triggers the stall in the first place. Not enforced via global `instructions` because that bloats every session's system prompt; better to add it as a per-project `AGENTS.md` rule when the repo is known to produce large generated files.
115
+
2. fill each section incrementally via multiple `edit` calls (~50–80 lines each, one logical block per call).
104
116
105
-
### When to remove the mitigation
117
+
This avoids the giant single-tool-call payload that triggers the stall in the first place. Empirically the most reliable fix in this session — far more effective than any client-side timeout tuning. Not enforced via global `instructions` because that bloats every session's system prompt; better to add it as a per-project `AGENTS.md` rule when the repo is known to produce large generated files.
106
118
107
-
The `chunkTimeout` override can stay indefinitely — it's a defensive setting that doesn't hurt. Reconsider when:
119
+
### When to revisit
108
120
109
-
- GitHub Copilot publishes that the proxy idle timeout has been raised or removed for the Anthropic channel, or
110
-
- you switch to direct Anthropic API (`provider.anthropic.options.apiKey`) and stop using the Copilot channel for Claude entirely.
121
+
- If `#20466` lands (one of PRs `#21727` / `#23501`), re-add `chunkTimeout` to the overlay — it will then actually retry instead of hard-failing.
122
+
- If `#17578` / PR `#18894` lands, the LSP-payload aggravator goes away upstream and the root `pyrightconfig.json` becomes a belt-and-suspenders defence rather than a load-bearing fix.
123
+
- If GitHub Copilot raises the proxy idle timeout, the entire section can be deleted and the overlay's `timeout` reverted to the upstream default.
124
+
- If you switch to direct Anthropic API (`provider.anthropic.options.apiKey`) and stop using the Copilot channel for Claude entirely, the overlay's `provider.github-copilot` block can be dropped.
"//": "Suppresses Pyright LSP noise from PEP 723 inline-script-deps Python files in this chezmoi repo. Auto-spawned LSPs append diagnostics to OpenCode tool responses (see docs/tools/opencode.md), inflating SSE payload size and aggravating GitHub Copilot proxy idle-timeout stalls — anomalyco/opencode#17578. This file lives at the chezmoi repo root, not under any dot_*/ source path, so it is git-tracked but never deployed to $HOME.",
0 commit comments