fix: harden long conversation continuity
Memind CI / Test, build, and release guards (push) Successful in 1m28s
Memind CI / Test, build, and release guards (push) Successful in 1m28s
This commit is contained in:
@@ -31,6 +31,47 @@ export function shouldPromoteSessionIdToStreaming(chatState) {
|
||||
return chatState !== 'idle';
|
||||
}
|
||||
|
||||
/**
|
||||
* A newly created Goose session can replay an empty Finish frame before the
|
||||
* current model request produces any activity. While a visible request is
|
||||
* active, that frame must not unlock the composer.
|
||||
*
|
||||
* @param {{ eventType?: string; tokenState?: object | null; hasActiveRequest?: boolean }} input
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function shouldIgnoreZeroActivityFinish({
|
||||
eventType,
|
||||
tokenState,
|
||||
hasActiveRequest = false,
|
||||
} = {}) {
|
||||
if (eventType !== 'Finish' || !hasActiveRequest || !tokenState) return false;
|
||||
const values = [
|
||||
tokenState.inputTokens,
|
||||
tokenState.outputTokens,
|
||||
tokenState.totalTokens,
|
||||
tokenState.accumulatedInputTokens,
|
||||
tokenState.accumulatedOutputTokens,
|
||||
tokenState.accumulatedTotalTokens,
|
||||
].filter((value) => value != null);
|
||||
return values.length > 0 && values.every((value) => Number(value) === 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* The session stream can temporarily report no Goose request while the
|
||||
* Portal agent-run is still authoritative and pending. Do not start the
|
||||
* missing-request idle timer until that outer run has reached a terminal
|
||||
* state.
|
||||
*
|
||||
* @param {{ allowMissingGrace?: boolean; agentRunPending?: boolean }} input
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function shouldScheduleMissingActiveRequestGrace({
|
||||
allowMissingGrace = false,
|
||||
agentRunPending = false,
|
||||
} = {}) {
|
||||
return allowMissingGrace && !agentRunPending;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only transport uncertainty may continue a run after submit fails. A
|
||||
* deterministic gateway error already has a terminal outcome and must return
|
||||
|
||||
Reference in New Issue
Block a user