MCPcopy Create free account
hub / github.com/AI45Lab/Code / restore_persisted_session_state

Function restore_persisted_session_state

core/src/agent_api/session_persistence.rs:203–243  ·  view source on GitHub ↗
(
    session: &AgentSession,
    store: &Arc<dyn SessionStore>,
    data: SessionData,
)

Source from the content-addressed store, hash-verified

201}
202
203pub(super) fn restore_persisted_session_state(
204 session: &AgentSession,
205 store: &Arc<dyn SessionStore>,
206 data: SessionData,
207) -> Result<()> {
208 let session_id = data.id.clone();
209 *write_or_recover(&session.history) = data.messages;
210
211 if let Some(artifacts) = load_artifacts(store, &session_id)? {
212 let target_store = session.tool_executor.artifact_store();
213 for artifact in artifacts.artifacts() {
214 target_store.put(artifact);
215 }
216 }
217
218 if let Some(events) = load_trace_events(store, &session_id)? {
219 session.trace_sink.replace_events(events);
220 }
221
222 if let Some(records) = load_run_records(store, &session_id)? {
223 if let Ok(handle) = tokio::runtime::Handle::try_current() {
224 tokio::task::block_in_place(|| {
225 handle.block_on(session.run_store.replace_records(records))
226 });
227 }
228 }
229
230 if let Some(reports) = load_verification_reports(store, &session_id)? {
231 *write_or_recover(&session.verification_reports) = reports;
232 }
233
234 if let Some(tasks) = load_subagent_tasks(store, &session_id)? {
235 if let Ok(handle) = tokio::runtime::Handle::try_current() {
236 tokio::task::block_in_place(|| {
237 handle.block_on(session.subagent_tasks.replace_snapshots(tasks))
238 });
239 }
240 }
241
242 Ok(())
243}
244
245struct SessionDataSnapshotInput<'a> {
246 session_id: &'a str,

Callers 1

resume_sessionFunction · 0.85

Calls 14

write_or_recoverFunction · 0.85
load_artifactsFunction · 0.85
load_trace_eventsFunction · 0.85
load_run_recordsFunction · 0.85
load_subagent_tasksFunction · 0.85
artifactsMethod · 0.80
putMethod · 0.80
replace_eventsMethod · 0.80
block_onMethod · 0.80
replace_recordsMethod · 0.80
replace_snapshotsMethod · 0.80

Tested by

no test coverage detected