From 47970e34440463f2f1149a462531ae99c22142f7 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Wed, 4 Feb 2026 13:45:47 +0100 Subject: [PATCH 1/2] Allow passing more env to docker run when running evals Signed-off-by: David Gageot --- cmd/root/eval.go | 1 + pkg/evaluation/eval.go | 12 ++++++++++++ pkg/evaluation/types.go | 1 + 3 files changed, 14 insertions(+) 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..814bd29c9 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 { + args = append(args, "-e", key) + env = append(env, key+"="+val) + } else if val, ok := r.runConfig.EnvProvider().Get(ctx, entry); ok { + 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 From 9ec4cc7d4a050f01e10f279a9d0ad6751248aef9 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Wed, 4 Feb 2026 13:51:12 +0100 Subject: [PATCH 2/2] Make reviewer happy Signed-off-by: David Gageot --- pkg/evaluation/eval.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/evaluation/eval.go b/pkg/evaluation/eval.go index 814bd29c9..a8b036c82 100644 --- a/pkg/evaluation/eval.go +++ b/pkg/evaluation/eval.go @@ -375,10 +375,10 @@ 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 { + 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 { + } else if val, ok := r.runConfig.EnvProvider().Get(ctx, entry); ok && entry != "" { args = append(args, "-e", entry) env = append(env, entry+"="+val) }