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
Every session fails to start with Instructions.InitializationBlocked: Instruction initialization blocked by unavailable sources: core/instructions. The root cause is a RangeError: Maximum call stack size exceeded (stack overflow) in the core/instructions source activation code. This affects both the shared background service and --standalone mode.
Environment
opencode version: 2.0.11 (latest, channel=latest)
OS: Windows 11 Pro, Build 22631, x64
Terminal: Windows Terminal / PowerShell 7
Shell: C:\WINDOWS\system32\cmd.exe / PowerShell 7
Install/channel: npm global install (@opencode/cli@2.0.11)
Active plugins: postgres (local plugin at ~/.config/opencode/plugins/postgres), herdr-agent-state.js, i-have-adhd.js
Reproduction
Install OpenCode v2.0.11 via npm (npm install -g @opencode/cli)
Run opencode (or opencode --standalone)
Create a new session
Session immediately fails with the error below
Expected Behavior
Session should start normally and process messages.
Actual Behavior
Every session fails immediately on creation. The logs show:
WARN "failed to activate instruction source"
cause="Cause([Die(RangeError: Maximum call stack size exceeded.)])"
ERROR "Failed to drain Session"
cause="Instructions.InitializationBlocked: Instruction initialization
blocked by unavailable sources: core/instructions
at FE (chunk-1sa5rvxc.js:30:42285)
at InstructionState.observe (chunk-1sa5rvxc.js:32:1283)
at InstructionState.prepare (chunk-vyhk950s.js:365:2744)
at SessionRunner.prepareContext (chunk-vyhk950s.js:365:2321)
at SessionRunner.advanceToStep (chunk-vyhk950s.js:365:2583)
at SessionRunner.drain (chunk-24mc5jhy.js:24:2279)"
This happens consistently across:
Multiple project directories
Both shared service and --standalone mode
After service restart (opencode service stop + restart)
After full computer restart
Additional Context
The core/instructions source crashes with infinite recursion before it can be marked as available, which then blocks session initialization.
Workaround attempted: opencode --standalone — same error occurs.
Config file is minimal (~/.config/opencode/opencode.json), AGENTS.md is only 756 bytes (16 lines).
Full log available at ~/.local/share/opencode/log/opencode.log (~45MB).
Reacted by VimWei, Jack Stringer and Dario Ruellan
Found the likely culprit — ancestorDirectories (packages/core/src/config/plugin/instruction.ts:133) recurses on dirname(start) and only terminates when start === stop. When the two paths don't string-match exactly (separator or case differences are easy to hit on Windows), the walk blows past stop, and since dirname("C:\\") keeps returning "C:\\" the recursion never bottoms out — hence the RangeError. That die is caught at :123, which marks the core/instructions source unavailable, so every session then fails with Instructions.InitializationBlocked — matching your trace exactly.
Fix is to bound the walk at the filesystem root instead of relying on the string comparison reaching stop. PR shortly.
OpenCode can be executed successfully in the following directories.
C:\Apps
C:\Users\chenw\Downloads\Documents
C:\Apps\AOE
C:\Apps\test\
The following steps were executed, resulting in the previous error.
C:\Apps\mdxpress
c:\Apps\dachu-commit
The analysis reveals a difference between these two scenarios: if previous sessions exist (e.g., opencode 1.x, but an upgrade to 2.x was performed during the initial run), an error occurs. If no previous sessions are present, the process runs normally.
Narrowed down: triggered by legacy 1.x session data, not by version
Not a duplicate — adding evidence to the existing diagnosis.
Project dir
Has 1.x session?
Result
C:\Apps
no
✅ works
C:\Apps\AOE
no
✅ works
C:\Apps\test
no
✅ works
C:\Users<me>\Downloads\Documents
no
✅ works
C:\Apps\mdxpress
yes
❌ InitializationBlocked
C:\Apps\dachu-commit
yes
❌ InitializationBlocked
Version is NOT the variable: 2.0.10 and 2.0.14 both reproduce.
Directory location is NOT the variable: C:\Apps works, C:\Apps\test works.
2.0.14 worked on very first run, before legacy sessions were loaded.
Every new session after that fails.
Hypothesis: one of start/stop in ancestorDirectories comes from the
working-directory field migrated from 1.x sessions, and it doesn't
string-match the current path (trailing slash / case / separator style).
@holny — a root-filesystem guard alone is not enough. When start and stop
are on different branches, the walk should return [] rather than the full
ancestor chain, otherwise the crash becomes a wrong result.
Gentle nudge — this has been open for a week with green checks and no review. The fix is small: ancestorDirectories walks iteratively with an explicit filesystem-root bound instead of recursing until two path strings compare equal, which overflows the stack on Windows when the forms drift. Covered by a dedicated regression test where stop is never an ancestor. Happy to rebase or adjust if anything needs changing.
Additional confirmation from Windows 11 Home 10.0.26220: this still reproduces on OpenCode 2.0.16 and 2.0.19.
Both versions logged the same instruction-source activation failure: failed to activate instruction source Cause([Die(RangeError: Maximum call stack size exceeded.)])
On 2.0.16, a subsequent session attempt failed with: Instructions.InitializationBlocked: Instruction initialization blocked by unavailable sources: core/instructions
with InstructionState.observe -> InstructionState.prepare -> SessionRunner.prepareContext.
That failed 2.0.16 session recorded zero cost and zero input/output tokens.
On 2.0.19, the server was running opencode-cli.exe serve --service. During the diagnostic period, POST /api/location/reload completed successfully while the same RangeError was logged. No provider call was made during this 2.0.19 diagnostic.
The 2.0.19 check did not establish a subsequent Instructions.InitializationBlocked / session-preparation failure.
Read-only checks found no AGENTS.md at ~/.config/opencode, the checked home directory, the workspace root, or its checked parent directories.
I have not isolated the triggering instruction source or confirmed that a case-variant location is the cause in this environment, so I am only reporting the observed symptom/version persistence here.
This extends the confirmed affected-version range beyond 2.0.14 to at least 2.0.19.
I'm having pretty same issue. v2.0.20. Its happening very random to me.
The issue somehow appears randomly and sometimes resolved when im killed running server (kill opencode.exe)
In some cases it looks to be depending on project (new session creating fine on empty projects and vice-versa: running fine on existing session and not creating on new projects)
Sometimes the full package reinstall helps and sometimes not...
I thought maybe it was a conflict with opencode v1 and tried to clean all caches and all configs which i could only find, but this doesn't looks to help much.
Activity
holny commentedon Sep 21, 2026
Found the likely culprit —
ancestorDirectories(packages/core/src/config/plugin/instruction.ts:133) recurses ondirname(start)and only terminates whenstart === stop. When the two paths don't string-match exactly (separator or case differences are easy to hit on Windows), the walk blows paststop, and sincedirname("C:\\")keeps returning"C:\\"the recursion never bottoms out — hence the RangeError. That die is caught at :123, which marks thecore/instructionssource unavailable, so every session then fails withInstructions.InitializationBlocked— matching your trace exactly.Fix is to bound the walk at the filesystem root instead of relying on the string comparison reaching
stop. PR shortly.VimWei commentedon Sep 23, 2026
The same issue, completely unusable.
OpenCode v2.0.10 - 2.0.14 via npm
VimWei commentedon Sep 23, 2026
OpenCode can be executed successfully in the following directories.
C:\Apps
C:\Users\chenw\Downloads\Documents
C:\Apps\AOE
C:\Apps\test\
The following steps were executed, resulting in the previous error.
C:\Apps\mdxpress
c:\Apps\dachu-commit
The analysis reveals a difference between these two scenarios: if previous sessions exist (e.g., opencode 1.x, but an upgrade to 2.x was performed during the initial run), an error occurs. If no previous sessions are present, the process runs normally.
VimWei commentedon Sep 23, 2026
Narrowed down: triggered by legacy 1.x session data, not by version
Not a duplicate — adding evidence to the existing diagnosis.
Every new session after that fails.
Hypothesis: one of start/stop in ancestorDirectories comes from the
working-directory field migrated from 1.x sessions, and it doesn't
string-match the current path (trailing slash / case / separator style).
@holny — a root-filesystem guard alone is not enough. When start and stop
are on different branches, the walk should return [] rather than the full
ancestor chain, otherwise the crash becomes a wrong result.
holny commentedon Sep 28, 2026
Gentle nudge — this has been open for a week with green checks and no review. The fix is small:
ancestorDirectorieswalks iteratively with an explicit filesystem-root bound instead of recursing until two path strings compare equal, which overflows the stack on Windows when the forms drift. Covered by a dedicated regression test wherestopis never an ancestor. Happy to rebase or adjust if anything needs changing.Diambiru commentedon Sep 29, 2026
Additional confirmation from Windows 11 Home 10.0.26220: this still reproduces on OpenCode 2.0.16 and 2.0.19.
failed to activate instruction sourceCause([Die(RangeError: Maximum call stack size exceeded.)])Instructions.InitializationBlocked: Instruction initialization blocked by unavailable sources: core/instructionswith
InstructionState.observe -> InstructionState.prepare -> SessionRunner.prepareContext.opencode-cli.exe serve --service. During the diagnostic period,POST /api/location/reloadcompleted successfully while the same RangeError was logged. No provider call was made during this 2.0.19 diagnostic.Instructions.InitializationBlocked/ session-preparation failure.AGENTS.mdat~/.config/opencode, the checked home directory, the workspace root, or its checked parent directories.I have not isolated the triggering instruction source or confirmed that a case-variant location is the cause in this environment, so I am only reporting the observed symptom/version persistence here.
This extends the confirmed affected-version range beyond 2.0.14 to at least 2.0.19.
rutexd commentedon Sep 30, 2026
I'm having pretty same issue. v2.0.20. Its happening very random to me.
The issue somehow appears randomly and sometimes resolved when im killed running server (kill opencode.exe)
In some cases it looks to be depending on project (new session creating fine on empty projects and vice-versa: running fine on existing session and not creating on new projects)
Sometimes the full package reinstall helps and sometimes not...
I thought maybe it was a conflict with opencode v1 and tried to clean all caches and all configs which i could only find, but this doesn't looks to help much.
Something is very strange happening here.
jack5github commentedon Oct 1, 2026
Since updating to v2.0.21, this has begun to affect every single folder I attempt to use OpenCode in, making the program completely unusable.