Repository navigation
Commit fba984a
myles
session: recover from dropped model streams with no terminal event
xAI/grok (and others) occasionally end a stream without a finish event —
keepalives keep arriving but completion is never signaled. Stream.runDrain
then never resolves, the assistant message is never finalized, and the
agent loop hangs: the session sits busy forever and can't accept prompts
(opencode anomalyco#11865/anomalyco#19023/anomalyco#32366; hermes-agent anomalyco#27197). byte-level
chunkTimeout can't catch this since keepalive bytes keep the socket warm.
Add an event-idle timeout (Stream.timeoutOrElse) on the model stream — a
healthy turn emits deltas continuously, so a 60s event gap means the
stream is dead. Failing routes into the existing retry/halt path, so the
turn finalizes (partial content + clear error) and the loop exits.
Verified against a keepalive-only mock: session recovers to idle.1 parent b155b15 commit fba984a
1 file changed
Lines changed: 21 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
637 | 640 | | |
638 | 641 | | |
639 | 642 | | |
640 | | - | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
641 | 661 | | |
642 | 662 | | |
643 | 663 | | |
| |||
0 commit comments