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

Function apply_event_to_snapshot

core/src/run.rs:465–500  ·  view source on GitHub ↗
(run: &mut RunSnapshot, event: &AgentEvent)

Source from the content-addressed store, hash-verified

463}
464
465fn apply_event_to_snapshot(run: &mut RunSnapshot, event: &AgentEvent) {
466 match event {
467 AgentEvent::Start { prompt } => {
468 run.status = RunStatus::Executing;
469 if run.prompt.is_empty() {
470 run.prompt = prompt.clone();
471 }
472 }
473 AgentEvent::PlanningStart { .. } => {
474 run.status = RunStatus::Planning;
475 }
476 AgentEvent::StepStart { .. }
477 | AgentEvent::ToolStart { .. }
478 | AgentEvent::TurnStart { .. }
479 if !matches!(run.status, RunStatus::Planning) =>
480 {
481 run.status = RunStatus::Executing;
482 }
483 AgentEvent::End { text, .. } => {
484 if run.status == RunStatus::Cancelled {
485 return;
486 }
487 run.status = RunStatus::Completed;
488 run.result_text = Some(text.clone());
489 run.error = None;
490 }
491 AgentEvent::Error { message } => {
492 if run.status == RunStatus::Cancelled {
493 return;
494 }
495 run.status = RunStatus::Failed;
496 run.error = Some(message.clone());
497 }
498 _ => {}
499 }
500}
501
502fn now_ms() -> u64 {
503 std::time::SystemTime::now()

Callers 1

record_eventMethod · 0.85

Calls 2

is_emptyMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected