Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/tui-opentui/runtime-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ export function attachSessionBridge(
stallTimeoutMs,
isProcessing: bag.turn.isProcessing,
streamingType: bag.turn.streamingType,
activeToolCalls: bag.turn.activeToolCalls,
}

if (shouldAbortForStall(stallArgs)) {
Expand Down
18 changes: 18 additions & 0 deletions src/tui-opentui/stall-watchdog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,19 @@ describe("shouldAbortForStall", () => {
stallTimeoutMs: STALL_TIMEOUT_MS,
isProcessing: true,
streamingType: null,
activeToolCalls: [],
}

test("a parallel fan-out with sibling tools still running is not a stall", () => {
const args = {
...base,
activeToolCalls: ["call-2"],
lastActivityAt: 0,
nowMs: 20 * 60_000,
}
expect(shouldAbortForStall(args)).toBe(false)
})

test("aborts an awaiting run past the timeout", () => {
expect(shouldAbortForStall(base)).toBe(true)
})
Expand Down Expand Up @@ -183,8 +194,15 @@ describe("shouldNoticeStall", () => {
isProcessing: true,
streamingType: null,
repeating: false,
activeToolCalls: [],
}

test("a parallel fan-out with sibling tools still running does not notice", () => {
expect(
shouldNoticeStall({ ...base, activeToolCalls: ["call-2"] }),
).toBe(false)
})

test("stays quiet while repeating, even if also silent by the clock", () => {
expect(shouldNoticeStall({ ...base, repeating: true })).toBe(false)
})
Expand Down
6 changes: 5 additions & 1 deletion src/tui-opentui/stall-watchdog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type ShouldAbortForStallArgs = {
readonly stallTimeoutMs: number
readonly isProcessing: boolean
readonly streamingType: "text" | "thinking" | "tool" | null
readonly activeToolCalls: readonly string[]
}

// The captured incident looped two sentences with no line break between them
Expand Down Expand Up @@ -116,7 +117,10 @@ function silentPastThreshold(
): boolean {
if (args.status !== "running") return false
if (args.nowMs - args.lastActivityAt < thresholdMs) return false
if (args.awaitingResponse) return true
// A parallel fan-out flips `awaitingResponse` true the moment any one
// sub-agent's tool call finishes, even while siblings are still running.
// Outstanding calls mean the run is not silent, regardless of that flag.
if (args.awaitingResponse && args.activeToolCalls.length === 0) return true
// Mid-stream hang: model stream stalled after first token. Long in-flight
// tool runs do not emit parent stream events; do not abort those.
return (
Expand Down
Loading