coro_core/agent/
execution.rs1use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct AgentExecution {
9 pub success: bool,
11
12 pub final_result: String,
14
15 pub steps_executed: usize,
17
18 pub duration_ms: u64,
20
21 pub data: Option<serde_json::Value>,
23
24 pub metadata: Option<HashMap<String, serde_json::Value>>,
26}
27
28impl AgentExecution {
29 pub fn success(final_result: String, steps_executed: usize, duration_ms: u64) -> Self {
31 Self {
32 success: true,
33 final_result,
34 steps_executed,
35 duration_ms,
36 data: None,
37 metadata: None,
38 }
39 }
40
41 pub fn failure(error: String, steps_executed: usize, duration_ms: u64) -> Self {
43 Self {
44 success: false,
45 final_result: format!("Execution failed: {}", error),
46 steps_executed,
47 duration_ms,
48 data: None,
49 metadata: None,
50 }
51 }
52
53 pub fn with_data(mut self, data: serde_json::Value) -> Self {
55 self.data = Some(data);
56 self
57 }
58
59 pub fn with_metadata(mut self, metadata: HashMap<String, serde_json::Value>) -> Self {
61 self.metadata = Some(metadata);
62 self
63 }
64}