Skip to content

Commit 74d499c

Browse files
committed
started adding optional schema
1 parent ebead66 commit 74d499c

File tree

1 file changed

+13
-3
lines changed
  • crates/chat-cli/src/cli/agent

1 file changed

+13
-3
lines changed

crates/chat-cli/src/cli/agent/mod.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ pub enum AgentConfigError {
131131
pub struct Agent {
132132
#[serde(
133133
rename = "$schema",
134-
default = "default_schema",
135-
skip_serializing_if = "String::is_empty"
134+
default,
135+
skip_serializing_if = "Option::is_none",
136+
deserialize_with = "deserialize_optional_string"
136137
)]
137-
pub schema: String,
138+
pub schema: Option,
138139
/// Name of the agent
139140
pub name: String,
140141
/// This field is not model facing and is mostly here for users to discern between agents
@@ -181,9 +182,18 @@ pub struct Agent {
181182
pub path: Option<PathBuf>,
182183
}
183184

185+
fn deserialize_optional_string<'de, D>(deserializer: D) -> Result, D::Error>
186+
where
187+
D: serde::Deserializer<'de>,
188+
{
189+
let opt = Option::::deserialize(deserializer)?;
190+
Ok(opt.filter(|s| !s.is_empty()))
191+
}
192+
184193
impl Default for Agent {
185194
fn default() -> Self {
186195
Self {
196+
schema: None,
187197
name: DEFAULT_AGENT_NAME.to_string(),
188198
description: Some("Default agent".to_string()),
189199
prompt: Default::default(),

0 commit comments

Comments
 (0)