Skip to content

fix(opencode): scope LLM stall timeout to subagent sessions only#411

Merged
randomm merged 1 commit intodevfrom
feature/issue-410-stall-timeout-subagent-only
Apr 12, 2026
Merged

fix(opencode): scope LLM stall timeout to subagent sessions only#411
randomm merged 1 commit intodevfrom
feature/issue-410-stall-timeout-subagent-only

Conversation

@randomm
Copy link
Copy Markdown
Owner

@randomm randomm commented Apr 12, 2026

Summary

Gates the LLM stream stall timeout to subagent sessions only (those spawned via the task tool with a parentID). Root/interactive PM sessions are now permanently exempt from the stall detector.

Problem

The 3-minute LLM stall timeout in processor.ts fired on ALL sessions indiscriminately. When the PM session called the question tool and waited for human input, no tokens flowed — so the stall detector incorrectly killed the session after 3 minutes.

Fix

  • Fetch Session.Info before the stream loop to access session.parentID
  • Gate the stall check on session.parentID being defined (line 94): only subagent sessions (spawned via task tool) get the timeout
  • Root sessions (parentID === undefined) are permanently exempt
  • Introduce StallError typed class so stall errors can be identified and re-thrown after cleanup runs (previously, stall errors were swallowed by the retry catch block)
  • Use stallErr save-and-rethrow pattern: stall error saved in catch, all cleanup runs, error re-thrown at end

Files Changed

  • packages/opencode/src/session/processor.ts — stall gate + StallError + cleanup-safe propagation
  • packages/opencode/test/session/processor-stall.test.ts — tests verifying parentID gating with real Session objects

Fixes #410

@randomm randomm merged commit 94b24ce into dev Apr 12, 2026
1 check passed
@randomm randomm deleted the feature/issue-410-stall-timeout-subagent-only branch April 12, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: LLM stall timeout fires on interactive PM sessions waiting for human input

1 participant