Skip to content

Commit a2f563f

Browse files
patnikoCopilot
andcommitted
test(rust): verify CustomAgentConfig model builder and serialization
Add unit tests for the with_model() builder, JSON serialization with model set, and confirming model is omitted from wire when None. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a7ef2f5 commit a2f563f

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

rust/src/types.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3208,6 +3208,31 @@ mod tests {
32083208
assert!(tool.skip_permission);
32093209
}
32103210

3211+
#[test]
3212+
fn custom_agent_config_builder_with_model() {
3213+
let agent = CustomAgentConfig::new("my-agent", "You are helpful.")
3214+
.with_model("claude-haiku-4.5")
3215+
.with_display_name("My Agent");
3216+
assert_eq!(agent.name, "my-agent");
3217+
assert_eq!(agent.model.as_deref(), Some("claude-haiku-4.5"));
3218+
assert_eq!(agent.display_name.as_deref(), Some("My Agent"));
3219+
}
3220+
3221+
#[test]
3222+
fn custom_agent_config_serializes_model() {
3223+
let agent = CustomAgentConfig::new("model-agent", "prompt").with_model("claude-haiku-4.5");
3224+
let wire = serde_json::to_value(&agent).unwrap();
3225+
assert_eq!(wire["model"], "claude-haiku-4.5");
3226+
assert_eq!(wire["name"], "model-agent");
3227+
}
3228+
3229+
#[test]
3230+
fn custom_agent_config_omits_model_when_none() {
3231+
let agent = CustomAgentConfig::new("no-model-agent", "prompt");
3232+
let wire = serde_json::to_value(&agent).unwrap();
3233+
assert!(wire.get("model").is_none());
3234+
}
3235+
32113236
#[test]
32123237
fn tool_with_parameters_handles_non_object_value() {
32133238
let tool = Tool::new("noop").with_parameters(json!(null));

0 commit comments

Comments
 (0)