huskies: merge 725_story_auto_swap_oauth_account_on_rate_limit
This commit is contained in:
@@ -126,6 +126,7 @@ pub(super) fn save_credentials(
|
||||
subscription_type: None,
|
||||
rate_limit_tier: None,
|
||||
rate_limited: false,
|
||||
rate_limit_reset_at: None,
|
||||
};
|
||||
oauth::upsert_pool_account(account).map_err(Error::TokenStorage)?;
|
||||
|
||||
|
||||
@@ -331,6 +331,30 @@ pub fn spawn_rate_limit_auto_scheduler(
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Try to swap to the next available OAuth account. On
|
||||
// success the next agent start (via auto-assign) will use
|
||||
// the freshly activated account — no long timer needed.
|
||||
// On failure (no pool or all accounts exhausted) fall back
|
||||
// to the existing timer-based retry path.
|
||||
match crate::llm::oauth::swap_to_next_available_account(reset_at).await {
|
||||
Ok(new_email) => {
|
||||
crate::slog!(
|
||||
"[timer] Account swap successful for story {story_id} \
|
||||
(agent {agent_name}): now using '{new_email}'. \
|
||||
Auto-assign will restart the agent with the new account."
|
||||
);
|
||||
// No timer needed — auto-assign picks up the story.
|
||||
continue;
|
||||
}
|
||||
Err(swap_err) => {
|
||||
crate::slog!(
|
||||
"[timer] Account swap not possible for story {story_id}: \
|
||||
{swap_err}. Falling back to timer-based retry."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
crate::slog!(
|
||||
"[timer] Auto-scheduling timer for story {story_id} \
|
||||
(agent {agent_name}) to resume at {reset_at}"
|
||||
|
||||
Reference in New Issue
Block a user