1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
7pub enum StreamingMode {
8 None,
10 SSE,
12 #[default]
14 Bidi,
15}
16
17#[derive(Debug, Clone)]
19pub struct RunConfig {
20 pub max_llm_calls: u32,
22 pub streaming_mode: StreamingMode,
24 pub save_input_blobs_as_artifacts: bool,
26 pub support_cfc: bool,
28 pub pause_on_tool_calls: bool,
30 pub output_key: Option<String>,
32 pub output_schema: Option<serde_json::Value>,
35}
36
37impl Default for RunConfig {
38 fn default() -> Self {
39 Self {
40 max_llm_calls: 500,
41 streaming_mode: StreamingMode::default(),
42 save_input_blobs_as_artifacts: false,
43 support_cfc: false,
44 pause_on_tool_calls: false,
45 output_key: None,
46 output_schema: None,
47 }
48 }
49}
50
51#[cfg(test)]
52mod tests {
53 use super::*;
54
55 #[test]
56 fn default_values() {
57 let config = RunConfig::default();
58 assert_eq!(config.max_llm_calls, 500);
59 assert_eq!(config.streaming_mode, StreamingMode::Bidi);
60 assert!(!config.save_input_blobs_as_artifacts);
61 assert!(!config.support_cfc);
62 assert!(!config.pause_on_tool_calls);
63 }
64
65 #[test]
66 fn streaming_mode_default_is_bidi() {
67 assert_eq!(StreamingMode::default(), StreamingMode::Bidi);
68 }
69
70 #[test]
71 fn clone_run_config() {
72 let config = RunConfig {
73 max_llm_calls: 100,
74 streaming_mode: StreamingMode::SSE,
75 save_input_blobs_as_artifacts: true,
76 support_cfc: true,
77 pause_on_tool_calls: true,
78 output_key: Some("result".to_string()),
79 output_schema: Some(serde_json::json!({"type": "object"})),
80 };
81 let cloned = config.clone();
82 assert_eq!(cloned.max_llm_calls, 100);
83 assert_eq!(cloned.streaming_mode, StreamingMode::SSE);
84 assert!(cloned.save_input_blobs_as_artifacts);
85 }
86
87 #[test]
88 fn streaming_mode_serde_roundtrip() {
89 let mode = StreamingMode::SSE;
90 let json = serde_json::to_string(&mode).unwrap();
91 let parsed: StreamingMode = serde_json::from_str(&json).unwrap();
92 assert_eq!(parsed, StreamingMode::SSE);
93 }
94}