Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/config/latest/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (c *Agents) UnmarshalYAML(unmarshal func(any) error) error {
}

var agent AgentConfig
if err := yaml.Unmarshal(valueBytes, &agent); err != nil {
if err := yaml.UnmarshalWithOptions(valueBytes, &agent, yaml.DisallowUnknownField()); err != nil {
return fmt.Errorf("failed to unmarshal agent config for %s: %w", name, err)
}

Expand Down
34 changes: 34 additions & 0 deletions pkg/config/latest/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,40 @@ func TestThinkingBudget_MarshalUnmarshal_Zero(t *testing.T) {
require.Equal(t, "thinking_budget: 0\n", string(output))
}

func TestAgents_UnmarshalYAML_RejectsUnknownFields(t *testing.T) {
t.Parallel()

// "instructions" (plural) is not a valid field; the correct field is "instruction" (singular).
// Agents.UnmarshalYAML must reject it so that typos don't silently drop config.
input := []byte(`version: "5"
agents:
root:
model: openai/gpt-4o
instructions: "You are a helpful assistant."
`)

_, err := Parse(input)
require.Error(t, err)
require.Contains(t, err.Error(), "instructions")
}

func TestAgents_UnmarshalYAML_AcceptsValidConfig(t *testing.T) {
t.Parallel()

input := []byte(`version: "5"
agents:
root:
model: openai/gpt-4o
instruction: "You are a helpful assistant."
`)

cfg, err := Parse(input)
require.NoError(t, err)
require.Len(t, cfg.Agents, 1)
require.Equal(t, "root", cfg.Agents[0].Name)
require.Equal(t, "You are a helpful assistant.", cfg.Agents[0].Instruction)
}

func TestRAGStrategyConfig_MarshalUnmarshal_FlattenedParams(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion pkg/config/v4/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (c *Agents) UnmarshalYAML(unmarshal func(any) error) error {
}

var agent AgentConfig
if err := yaml.Unmarshal(valueBytes, &agent); err != nil {
if err := yaml.UnmarshalWithOptions(valueBytes, &agent, yaml.DisallowUnknownField()); err != nil {
return fmt.Errorf("failed to unmarshal agent config for %s: %w", name, err)
}

Expand Down
34 changes: 34 additions & 0 deletions pkg/config/v4/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,40 @@ func TestThinkingBudget_MarshalUnmarshal_Zero(t *testing.T) {
require.Equal(t, "thinking_budget: 0\n", string(output))
}

func TestAgents_UnmarshalYAML_RejectsUnknownFields(t *testing.T) {
t.Parallel()

// "instructions" (plural) is not a valid field; the correct field is "instruction" (singular).
// Agents.UnmarshalYAML must reject it so that typos don't silently drop config.
input := []byte(`version: "4"
agents:
root:
model: openai/gpt-4o
instructions: "You are a helpful assistant."
`)

_, err := Parse(input)
require.Error(t, err)
require.Contains(t, err.Error(), "instructions")
}

func TestAgents_UnmarshalYAML_AcceptsValidConfig(t *testing.T) {
t.Parallel()

input := []byte(`version: "4"
agents:
root:
model: openai/gpt-4o
instruction: "You are a helpful assistant."
`)

cfg, err := Parse(input)
require.NoError(t, err)
require.Len(t, cfg.Agents, 1)
require.Equal(t, "root", cfg.Agents[0].Name)
require.Equal(t, "You are a helpful assistant.", cfg.Agents[0].Instruction)
}

func TestRAGStrategyConfig_MarshalUnmarshal_FlattenedParams(t *testing.T) {
t.Parallel()

Expand Down