Skip to content

Commit 735fb77

Browse files
authored
fix(agent): name not being made optional (#2410)
1 parent 7fdd94e commit 735fb77

File tree

1 file changed

+11
-9
lines changed
  • crates/chat-cli/src/cli/agent

1 file changed

+11
-9
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,8 @@ pub enum AgentConfigError {
120120
#[serde(rename_all = "camelCase", deny_unknown_fields)]
121121
#[schemars(description = "An Agent is a declarative way of configuring a given instance of q chat.")]
122122
pub struct Agent {
123-
/// Agent names are derived from the file name. Thus they are skipped for
124-
/// serializing
125-
#[serde(skip)]
123+
/// Agent names are optional. If they are not provided they are derived from the file name
124+
#[serde(default)]
126125
pub name: String,
127126
/// This field is not model facing and is mostly here for users to discern between agents
128127
#[serde(default)]
@@ -211,13 +210,16 @@ impl Agent {
211210
fn thaw(&mut self, path: &Path, global_mcp_config: Option<&McpServerConfig>) -> Result<(), AgentConfigError> {
212211
let Self { mcp_servers, .. } = self;
213212

214-
let name = path
215-
.file_stem()
216-
.ok_or(AgentConfigError::MissingFilename)?
217-
.to_string_lossy()
218-
.to_string();
213+
if self.name.is_empty() {
214+
let name = path
215+
.file_stem()
216+
.ok_or(AgentConfigError::MissingFilename)?
217+
.to_string_lossy()
218+
.to_string();
219+
220+
self.name = name;
221+
}
219222

220-
self.name = name.clone();
221223
self.path = Some(path.to_path_buf());
222224

223225
if let (true, Some(global_mcp_config)) = (self.use_legacy_mcp_json, global_mcp_config) {

0 commit comments

Comments
 (0)