a3s-code-core 5.2.2

A3S Code Core - Embeddable AI agent library with tool execution
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Host-facing session save control.
//!
//! Persistence snapshots are owned by `session_persistence`; this module keeps
//! the public `save()` entrypoint thin without exposing snapshot construction to
//! the facade.

use super::{session_persistence::SessionPersistenceContext, AgentSession};
use crate::error::Result;

pub(super) async fn save(session: &AgentSession) -> Result<()> {
    // A manual save must not sample history, usage, tasks, and artifacts from
    // different points in an active conversation. Auto-save runs inside the
    // admitted run lifecycle and calls `SessionPersistenceContext` directly.
    let _lease = session.run_admission.try_acquire(&session.session_id)?;
    SessionPersistenceContext::from_session(session)
        .save()
        .await
}