Commit 619020d
fix: refresh subagent idle timeout on tool-activity heartbeat
When a subagent performs long-running tool calls (e.g. web_fetch, read,
exec), the LLM stream is idle. If no LLM token arrives within 120 seconds,
the session is terminated with LLM idle timeout.
This fix adds a tool-activity heartbeat mechanism:
- A new module tool-activity-heartbeat.ts provides a subscription/
notification pair (onToolActivity / notifyToolActivity) modelled on the
existing llm-request-activity pattern.
- streamWithIdleTimeout (llm-idle-timeout.ts) now subscribes to both
LLM-request activity AND tool-activity, resetting the idle timer via
armTimer() on either signal.
- attempt.ts calls notifyToolActivity(runAbortController.signal) after
every completed tool call (both success and failure branches), so the
idle watchdog sees activity even when the model is silent.
The 30-second heartbeat window (TOOL_ACTIVITY_HEARTBEAT_MS = 30_000) is
intentionally shorter than the default 120s idle timeout, giving slow
tool calls multiple chances to refresh before the watchdog fires.
Fixes #941241 parent 8b8b134 commit 619020d
3 files changed
Lines changed: 61 additions & 0 deletions
File tree
- src/agents/embedded-agent-runner/run
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
| 482 | + | |
482 | 483 | | |
483 | 484 | | |
484 | 485 | | |
| |||
3677 | 3678 | | |
3678 | 3679 | | |
3679 | 3680 | | |
| 3681 | + | |
3680 | 3682 | | |
3681 | 3683 | | |
3682 | 3684 | | |
| |||
3692 | 3694 | | |
3693 | 3695 | | |
3694 | 3696 | | |
| 3697 | + | |
3695 | 3698 | | |
3696 | 3699 | | |
3697 | 3700 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
296 | 297 | | |
297 | 298 | | |
298 | 299 | | |
| 300 | + | |
299 | 301 | | |
300 | 302 | | |
301 | 303 | | |
| 304 | + | |
302 | 305 | | |
303 | 306 | | |
304 | 307 | | |
| |||
Lines changed: 55 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
0 commit comments