fix(chat): recover active requests and preserve finish order

This commit is contained in:
john
2026-07-16 21:04:32 +08:00
parent 933466c8ab
commit c1012da120
4 changed files with 65 additions and 3 deletions
+9 -2
View File
@@ -39,8 +39,15 @@ export function shouldPromoteSessionIdToStreaming(chatState) {
* @param {number | undefined | null} status
* @returns {boolean}
*/
export function shouldKeepStreamingAfterRunError(status) {
return status === 0 || status === 409 || Number(status) >= 500;
export function shouldKeepStreamingAfterRunError(status, message = '', code = '') {
if (status === 0 || status === 409 || Number(status) >= 500) return true;
// Goose can surface the session-level concurrency guard as a failed agent
// run (rather than an HTTP 409). The request may already be streaming and
// the session SSE is still the source of truth, so recover from the session
// instead of showing a terminal error in the chat composer.
const text = `${String(code ?? '')} ${String(message ?? '')}`.toLowerCase();
return text.includes('session already has an active request')
|| text.includes('active request. cancel it first');
}
/**