fix(ai): forget the remembered working provider when the chain is saved

The in-memory memo of the last provider that answered reorders the
chain for up to an hour. Saving a new chain now drops it for that
account, so a provider the person removed or disabled no longer leads
the chain they just arranged.
This commit is contained in:
Marc-André Bombeck committed 2026-10-03 18:04:09 +02:00
1 parent 916f918674
commit 7022b698e7
4 files changed
+24 -1

No files matched your search

+9
View File
@@ -98,6 +98,15 @@ export function getLastWorkingProvider(
return entry.providerType;
}
/**
* Drop one user's "last working provider" memo. Called when the person saves
* a new chain: the memo reorders the chain they just arranged, and a provider
* they removed or disabled must not keep leading it for up to an hour.
*/
export function forgetLastWorkingProvider(userId: string): void {
lastWorkingCache.delete(userId);
}
function rememberWorkingProvider(
userId: string,
providerType: ProviderChainType,