diff --git a/src/QueryEngine.ts b/src/QueryEngine.ts index 6704dac68..030d93f0c 100644 --- a/src/QueryEngine.ts +++ b/src/QueryEngine.ts @@ -1116,6 +1116,7 @@ export class QueryEngine { duration_ms: Date.now() - startTime, duration_api_ms: getTotalAPIDuration(), is_error: true, + is_interrupted: this.abortController.signal.aborted, num_turns: turnCount, stop_reason: lastStopReason, session_id: getSessionId(), @@ -1128,11 +1129,6 @@ export class QueryEngine { initialAppState.fastMode, ), uuid: randomUUID(), - // Diagnostic prefix: these are what isResultSuccessful() checks — if - // the result type isn't assistant-with-text/thinking or user-with- - // tool_result, and stop_reason isn't end_turn, that's why this fired. - // errors[] is turn-scoped via the watermark; previously it dumped the - // entire process's logError buffer (ripgrep timeouts, ENOENT, etc). errors: (() => { const all = getInMemoryErrors() const start = errorLogWatermark diff --git a/src/server/sessionHandle.ts b/src/server/sessionHandle.ts index 9482894b6..500627029 100644 --- a/src/server/sessionHandle.ts +++ b/src/server/sessionHandle.ts @@ -684,18 +684,19 @@ export class SessionHandle { }) this.writeStdin(interrupt) + if (!this.promptResolve) return + await new Promise(resolve => { const timeout = setTimeout(() => { this.kill() resolve() - }, 5000) - const check = setInterval(() => { - if (!this.child || this.child.killed) { - clearTimeout(timeout) - clearInterval(check) - resolve() - } - }, 200) + }, 2000) + const originalResolve = this.promptResolve + this.promptResolve = (value) => { + clearTimeout(timeout) + originalResolve?.(value) + resolve() + } }) }