use super::store::{self, AgentEntry};
use crate::session::Session;
use anyhow::Result;
pub(super) async fn persist_spawned_agent(
name: &str,
instructions: &str,
session: Session,
) -> Result<()> {
save_session(name, &session).await?;
store::insert(
name.to_string(),
AgentEntry {
instructions: instructions.to_string(),
session,
},
);
Ok(())
}
async fn save_session(name: &str, session: &Session) -> Result<()> {
session.save().await.map_err(|error| {
tracing::warn!(agent = %name, error = %error, "Failed to save spawned agent session");
error
})
}