autoagents_core/agent/
result.rs

1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct AgentRunResult {
6    /// Indicates if the run was successful
7    pub success: bool,
8
9    /// The actual output of the agent, if any
10    pub output: Option<Value>,
11
12    /// Optional error message if failed
13    pub error_message: Option<String>,
14
15    /// Additional metadata, e.g. timestamps, logs, etc.
16    pub metadata: Option<Value>,
17}
18
19impl AgentRunResult {
20    /// Helper to create a success result
21    pub fn success(output: Value) -> Self {
22        Self {
23            success: true,
24            output: Some(output),
25            error_message: None,
26            metadata: None,
27        }
28    }
29
30    /// Helper to create a failure result
31    pub fn failure(error_message: String) -> Self {
32        Self {
33            success: false,
34            output: None,
35            error_message: Some(error_message),
36            metadata: None,
37        }
38    }
39}