fix: restore provider and extensions for LRU-evicted sessions (#7616)
This commit is contained in:
@@ -95,10 +95,30 @@ impl AgentManager {
|
|||||||
GoosePlatform::GooseDesktop,
|
GoosePlatform::GooseDesktop,
|
||||||
);
|
);
|
||||||
let agent = Arc::new(Agent::with_config(config));
|
let agent = Arc::new(Agent::with_config(config));
|
||||||
if let Some(provider) = &*self.default_provider.read().await {
|
|
||||||
agent
|
if let Ok(session) = self.session_manager.get_session(&session_id, false).await {
|
||||||
.update_provider(Arc::clone(provider), &session_id)
|
if session.provider_name.is_some() {
|
||||||
.await?;
|
info!(
|
||||||
|
"Restoring evicted session {} (provider: {:?})",
|
||||||
|
session_id, session.provider_name
|
||||||
|
);
|
||||||
|
if let Err(e) = agent.restore_provider_from_session(&session).await {
|
||||||
|
tracing::warn!(
|
||||||
|
"Failed to restore provider for session {}: {}",
|
||||||
|
session_id,
|
||||||
|
e
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
agent.load_extensions_from_session(&session).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
if agent.provider().await.is_err() {
|
||||||
|
if let Some(provider) = &*self.default_provider.read().await {
|
||||||
|
agent
|
||||||
|
.update_provider(Arc::clone(provider), &session_id)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut sessions = self.sessions.write().await;
|
let mut sessions = self.sessions.write().await;
|
||||||
|
|||||||
Reference in New Issue
Block a user