Skip to content

Commit 4ecd15e

Browse files
patnikoCopilot
andcommitted
test(go): verify CustomAgentConfig model JSON serialization
Add tests asserting that the model field round-trips through JSON when set and is omitted from the payload when empty. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1f4de3c commit 4ecd15e

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

go/types_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,49 @@ func TestProviderConfig_JSONOmitsUnsetTokenFields(t *testing.T) {
216216
}
217217
}
218218
}
219+
220+
func TestCustomAgentConfig_JSONIncludesModel(t *testing.T) {
221+
cfg := CustomAgentConfig{
222+
Name: "model-agent",
223+
Prompt: "You are a model agent.",
224+
Model: "claude-haiku-4.5",
225+
}
226+
227+
data, err := json.Marshal(cfg)
228+
if err != nil {
229+
t.Fatalf("failed to marshal CustomAgentConfig: %v", err)
230+
}
231+
232+
var decoded map[string]any
233+
if err := json.Unmarshal(data, &decoded); err != nil {
234+
t.Fatalf("failed to unmarshal CustomAgentConfig: %v", err)
235+
}
236+
237+
if decoded["model"] != "claude-haiku-4.5" {
238+
t.Errorf("expected model 'claude-haiku-4.5', got %v", decoded["model"])
239+
}
240+
if decoded["name"] != "model-agent" {
241+
t.Errorf("expected name 'model-agent', got %v", decoded["name"])
242+
}
243+
}
244+
245+
func TestCustomAgentConfig_JSONOmitsModelWhenEmpty(t *testing.T) {
246+
cfg := CustomAgentConfig{
247+
Name: "no-model-agent",
248+
Prompt: "You are an agent without a model.",
249+
}
250+
251+
data, err := json.Marshal(cfg)
252+
if err != nil {
253+
t.Fatalf("failed to marshal CustomAgentConfig: %v", err)
254+
}
255+
256+
var decoded map[string]any
257+
if err := json.Unmarshal(data, &decoded); err != nil {
258+
t.Fatalf("failed to unmarshal CustomAgentConfig: %v", err)
259+
}
260+
261+
if _, present := decoded["model"]; present {
262+
t.Errorf("expected model to be omitted when empty, got %v", decoded["model"])
263+
}
264+
}

0 commit comments

Comments
 (0)