MCPcopy Index your code
hub / github.com/AI45Lab/Code / persist_loop_checkpoint

Method persist_loop_checkpoint

core/src/agent/loop_runtime.rs:171–195  ·  view source on GitHub ↗

Persist a `LoopCheckpoint` if both a sink and a bound run id are configured. Failures are swallowed (the sink already logs them) so an unavailable store cannot halt a live run.

(
        &self,
        turn: usize,
        state: &super::execution_state::ExecutionLoopState,
        session_id: Option<&str>,
    )

Source from the content-addressed store, hash-verified

169 /// configured. Failures are swallowed (the sink already logs them)
170 /// so an unavailable store cannot halt a live run.
171 async fn persist_loop_checkpoint(
172 &self,
173 turn: usize,
174 state: &super::execution_state::ExecutionLoopState,
175 session_id: Option<&str>,
176 ) {
177 let Some(sink) = self.checkpoint_sink.as_ref() else {
178 return;
179 };
180 let Some(run_id) = self.checkpoint_run_id.as_ref() else {
181 return;
182 };
183 let checkpoint = crate::loop_checkpoint::LoopCheckpoint {
184 schema_version: crate::loop_checkpoint::LOOP_CHECKPOINT_SCHEMA_VERSION,
185 run_id: run_id.clone(),
186 session_id: session_id.unwrap_or("").to_string(),
187 turn,
188 messages: state.messages.clone(),
189 total_usage: state.total_usage.clone(),
190 tool_calls_count: state.tool_calls_count,
191 verification_reports: state.verification_reports.clone(),
192 checkpoint_ms: self.config.host_env.now_ms(),
193 };
194 sink.save_checkpoint(&checkpoint).await;
195 }
196}

Callers 1

execute_loop_innerMethod · 0.80

Calls 3

now_msMethod · 0.80
save_checkpointMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected