diff --git a/cmd/root/eval.go b/cmd/root/eval.go index 4b3183c20..8f3fc6df6 100644 --- a/cmd/root/eval.go +++ b/cmd/root/eval.go @@ -43,6 +43,7 @@ func newEvalCmd() *cobra.Command { cmd.Flags().StringSliceVar(&flags.Only, "only", nil, "Only run evaluations with file names matching these patterns (can be specified multiple times)") cmd.Flags().StringVar(&flags.BaseImage, "base-image", "", "Custom base Docker image for running evaluations") cmd.Flags().BoolVar(&flags.KeepContainers, "keep-containers", false, "Keep containers after evaluation (don't use --rm)") + cmd.Flags().StringSliceVarP(&flags.EnvVars, "env", "e", nil, "Environment variables to pass to container (KEY or KEY=VALUE)") return cmd } diff --git a/pkg/evaluation/eval.go b/pkg/evaluation/eval.go index 69258b765..a8b036c82 100644 --- a/pkg/evaluation/eval.go +++ b/pkg/evaluation/eval.go @@ -372,6 +372,18 @@ func (r *Runner) runCagentInContainer(ctx context.Context, imageID, question str } } + // Pass additional environment variables specified via -e flag + // Format: KEY or KEY=VALUE + for _, entry := range r.EnvVars { + if key, val, hasValue := strings.Cut(entry, "="); hasValue && key != "" { + args = append(args, "-e", key) + env = append(env, key+"="+val) + } else if val, ok := r.runConfig.EnvProvider().Get(ctx, entry); ok && entry != "" { + args = append(args, "-e", entry) + env = append(env, entry+"="+val) + } + } + args = append(args, imageID, "/configs/"+agentFile, question) cmd := exec.CommandContext(ctx, "docker", args...) diff --git a/pkg/evaluation/types.go b/pkg/evaluation/types.go index e69fc9768..b4f6aa60f 100644 --- a/pkg/evaluation/types.go +++ b/pkg/evaluation/types.go @@ -120,6 +120,7 @@ type Config struct { Only []string // Only run evaluations matching these patterns BaseImage string // Custom base Docker image for running evaluations KeepContainers bool // If true, don't remove containers after evaluation (skip --rm) + EnvVars []string // Environment variables to pass: KEY (value from env) or KEY=VALUE (explicit) } // Session helper functions