use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum StreamingMode {
None,
SSE,
#[default]
Bidi,
}
#[derive(Debug, Clone)]
pub struct RunConfig {
pub max_llm_calls: u32,
pub streaming_mode: StreamingMode,
pub save_input_blobs_as_artifacts: bool,
pub support_cfc: bool,
pub pause_on_tool_calls: bool,
pub output_key: Option<String>,
pub output_schema: Option<serde_json::Value>,
}
impl Default for RunConfig {
fn default() -> Self {
Self {
max_llm_calls: 500,
streaming_mode: StreamingMode::default(),
save_input_blobs_as_artifacts: false,
support_cfc: false,
pause_on_tool_calls: false,
output_key: None,
output_schema: None,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn default_values() {
let config = RunConfig::default();
assert_eq!(config.max_llm_calls, 500);
assert_eq!(config.streaming_mode, StreamingMode::Bidi);
assert!(!config.save_input_blobs_as_artifacts);
assert!(!config.support_cfc);
assert!(!config.pause_on_tool_calls);
}
#[test]
fn streaming_mode_default_is_bidi() {
assert_eq!(StreamingMode::default(), StreamingMode::Bidi);
}
#[test]
fn clone_run_config() {
let config = RunConfig {
max_llm_calls: 100,
streaming_mode: StreamingMode::SSE,
save_input_blobs_as_artifacts: true,
support_cfc: true,
pause_on_tool_calls: true,
output_key: Some("result".to_string()),
output_schema: Some(serde_json::json!({"type": "object"})),
};
let cloned = config.clone();
assert_eq!(cloned.max_llm_calls, 100);
assert_eq!(cloned.streaming_mode, StreamingMode::SSE);
assert!(cloned.save_input_blobs_as_artifacts);
}
#[test]
fn streaming_mode_serde_roundtrip() {
let mode = StreamingMode::SSE;
let json = serde_json::to_string(&mode).unwrap();
let parsed: StreamingMode = serde_json::from_str(&json).unwrap();
assert_eq!(parsed, StreamingMode::SSE);
}
}