fix(auth): serialize profile stats updates

This commit is contained in:
Peter Steinberger
2026-01-07 01:06:51 +01:00
parent 96d72ff91e
commit 19c95d0ff7
2 changed files with 24 additions and 25 deletions

View File

@@ -1000,7 +1000,7 @@ export async function runEmbeddedPiAgent(params: {
if (shouldRotate) {
// Mark current profile for cooldown before rotating
if (lastProfileId) {
markAuthProfileCooldown({
await markAuthProfileCooldown({
store: authStore,
profileId: lastProfileId,
});
@@ -1091,13 +1091,16 @@ export async function runEmbeddedPiAgent(params: {
`embedded run done: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - started} aborted=${aborted}`,
);
if (lastProfileId) {
markAuthProfileGood({
await markAuthProfileGood({
store: authStore,
provider,
profileId: lastProfileId,
});
// Track usage for round-robin rotation
markAuthProfileUsed({ store: authStore, profileId: lastProfileId });
await markAuthProfileUsed({
store: authStore,
profileId: lastProfileId,
});
}
return {
payloads: payloads.length ? payloads : undefined,