File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
crates/chat-cli/src/cli/agent Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -120,9 +120,8 @@ pub enum AgentConfigError {
120
120
#[ serde( rename_all = "camelCase" , deny_unknown_fields) ]
121
121
#[ schemars( description = "An Agent is a declarative way of configuring a given instance of q chat." ) ]
122
122
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 ) ]
126
125
pub name : String ,
127
126
/// This field is not model facing and is mostly here for users to discern between agents
128
127
#[ serde( default ) ]
@@ -211,13 +210,16 @@ impl Agent {
211
210
fn thaw ( & mut self , path : & Path , global_mcp_config : Option < & McpServerConfig > ) -> Result < ( ) , AgentConfigError > {
212
211
let Self { mcp_servers, .. } = self ;
213
212
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
+ }
219
222
220
- self . name = name. clone ( ) ;
221
223
self . path = Some ( path. to_path_buf ( ) ) ;
222
224
223
225
if let ( true , Some ( global_mcp_config) ) = ( self . use_legacy_mcp_json , global_mcp_config) {
You can’t perform that action at this time.
0 commit comments