Skip to content
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
times configurations times iterations. A benchmark over four cases with
`--iteration 5` previously reported only `Would run 4 case(s)` for 40
executions. A negative `--iteration` is now rejected in a dry run as well.
- Reject a negative `constraints.timeout_seconds` or `constraints.max_turns`
in a case. Both silently fell back to the eval defaults.
`cases.defaults.timeout_seconds: -1` still disables the case deadline.
- Warn when a selected case has no judge rule, no `expect` check and no turn
`post_condition`. Such a case can pass without anything checking the
agent's output, and its report read the same as a case that passed its
Expand Down
15 changes: 15 additions & 0 deletions internal/config/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ func (v *Validator) ValidateCaseConfig(cfg *CaseConfig) error {
errs = append(errs, validateExpect("expect", cfg.Expect)...)

errs = append(errs, validateCaseMCP(cfg.MCP)...)
errs = append(errs, validateConstraintLimits(cfg.Constraints)...)

if len(errs) > 0 {
return fmt.Errorf("validation errors:\n - %s", strings.Join(errs, "\n - "))
Expand Down Expand Up @@ -558,6 +559,20 @@ func validateCollectArtifacts(field string, patterns []string) []string {
return errs
}

// validateConstraintLimits rejects negative per-case limits, which would
// otherwise fall back to the defaults silently. Only cases.defaults accepts a
// negative timeout, as the opt-out from the case deadline.
func validateConstraintLimits(c Constraints) []string {
var errs []string
if c.MaxTurns < 0 {
errs = append(errs, "constraints.max_turns must be non-negative; 0 uses cases.defaults.max_turns")
}
if c.TimeoutSeconds < 0 {
errs = append(errs, "constraints.timeout_seconds must be non-negative; 0 uses cases.defaults.timeout_seconds, and cases.defaults.timeout_seconds: -1 disables the deadline")
}
return errs
}

func validatePassThreshold(threshold *float64) []string {
if threshold == nil {
return nil
Expand Down
20 changes: 20 additions & 0 deletions internal/config/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ import (
"testing"
)

func TestNegativeCaseExecutionLimits(t *testing.T) {
t.Parallel()
for _, value := range []int{-1, 0, 1} {
cfg := DefaultEvalConfig()
cfg.Cases.Files = []string{"case.yaml"}
cfg.Cases.Defaults.MaxTurns, cfg.Cases.Defaults.TimeoutSeconds = value, value
if err := NewValidator().ValidateEvalConfig(cfg); err != nil {
t.Errorf("cases.defaults limit %d rejected; -1 must stay the opt-out: %v", value, err)
}
c := &CaseConfig{Input: Input{Prompt: "read"}, Constraints: Constraints{MaxTurns: value, TimeoutSeconds: value}}
err := NewValidator().ValidateCaseConfig(c)
switch {
case value >= 0 && err != nil:
t.Errorf("constraints limit %d rejected: %v", value, err)
case value < 0 && (err == nil || !strings.Contains(err.Error(), "constraints.max_turns") || !strings.Contains(err.Error(), "constraints.timeout_seconds")):
t.Errorf("negative constraints accepted or field missing: %v", err)
}
}
}

func TestEnvironmentAgentHome(t *testing.T) {
for _, kind := range []string{runtimeTypeNone, runtimeTypeDocker, runtimeTypeOpenSandbox} {
for _, mode := range []string{"", "inherited", "temporary", "unknown"} {
Expand Down
Loading