JuliusBrussee/caveman · error

optimizer %q not found in trial %s

Error message

optimizer %q not found in trial %s

What it means

promoteMove searched the trial plan's Moves for the given optimizer_id and found no candidate with that OptimizerID. The plan comes from BuildTrialPlan(trialID) computed in this invocation, so the optimizer must be part of that trial's current plan. fatalJSON exits 1 before any candidate file is written.

Source

Thrown at proxy/cmd/caveman-proxy/main.go:763

	if err != nil {
		fatalJSON(logger, err)
	}
	if latest == "" {
		fatalJSON(logger, fmt.Errorf("no trial_id supplied and no trial runs exist"))
	}
	return latest
}

func promoteMove(logger *slog.Logger, home, trialID, optimizerID string, plan store.TrialPlan) {
	var move store.TrialMove
	for _, candidate := range plan.Moves {
		if candidate.OptimizerID == optimizerID {
			move = candidate
			break
		}
	}
	if move.OptimizerID == "" {
		fatalJSON(logger, fmt.Errorf("optimizer %q not found in trial %s", optimizerID, trialID))
	}
	if move.Status != "safe_now" || !(strings.HasPrefix(move.SafetyClass, "S0_") || strings.HasPrefix(move.SafetyClass, "S1_")) {
		path := filepath.Join(home, "reports", "caveman-trial-"+trialID+"-"+optimizerID+"-candidate.yaml")
		if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
			fatalJSON(logger, err)
		}
		raw, _ := yaml.Marshal(map[string]any{
			"mode":         "record",
			"optimizers":   map[string]bool{optimizerID: true},
			"eval_command": "caveman evals run",
		})
		if err := os.WriteFile(path, raw, 0o600); err != nil {
			fatalJSON(logger, err)
		}
		printJSON(map[string]any{
			"trial_id": trialID, "optimizer_id": optimizerID, "promoted": false,
			"candidate_config": path, "eval_command": "caveman evals run",
			"reason": "move is not safe_now S0/S1",

View on GitHub (pinned to 27d5a3981a)

Solutions

  1. Inspect the trial plan first: caveman-proxy trial export --trial-id <id> lists the Moves with their optimizer ids — copy the id exactly from there
  2. Confirm the optimizer id belongs to this trial, not another
  3. If the id vanished after an upgrade, re-run the trial under the current binary so the plan reflects live heuristics

Example fix

# before
caveman-proxy trial promote model-right-sizing --trial-id abc123

# after
caveman-proxy trial export --trial-id abc123          # see valid Moves
caveman-proxy trial promote compress-prefix --trial-id abc123
Defensive patterns

Strategy: validation

Validate before calling

OPT_IDS=$(caveman-proxy trial export --trial-id "$TRIAL_ID" | jq -r '.moves[].optimizer_id')
echo "$OPT_IDS" | grep -qx "$OPT_ID" || { echo "invalid optimizer id" >&2; exit 2; }
caveman-proxy trial promote "$OPT_ID" --trial-id "$TRIAL_ID"

Prevention

When it happens

Trigger: Passing an optimizer id that belongs to a different trial, a typo/case mismatch, or an id from an older plan revision where the optimizer was renamed or dropped (e.g. heuristics that no longer emit retired ids like model-right-sizing).

Common situations: Copy-pasting optimizer ids across trials; plans regenerated after a binary upgrade with changed heuristics; retired optimizer ids lingering in notes or scripts.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15). Data as JSON: /api/errors/14312572bcd89160. Report an issue: GitHub.