Skip to content

Commit d9c56aa

Browse files
authored
Merge pull request #1585 from dgageot/eval-env
Allow passing more env to docker run when running evals
2 parents 21cff5d + 9ec4cc7 commit d9c56aa

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

cmd/root/eval.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func newEvalCmd() *cobra.Command {
4343
cmd.Flags().StringSliceVar(&flags.Only, "only", nil, "Only run evaluations with file names matching these patterns (can be specified multiple times)")
4444
cmd.Flags().StringVar(&flags.BaseImage, "base-image", "", "Custom base Docker image for running evaluations")
4545
cmd.Flags().BoolVar(&flags.KeepContainers, "keep-containers", false, "Keep containers after evaluation (don't use --rm)")
46+
cmd.Flags().StringSliceVarP(&flags.EnvVars, "env", "e", nil, "Environment variables to pass to container (KEY or KEY=VALUE)")
4647

4748
return cmd
4849
}

pkg/evaluation/eval.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,18 @@ func (r *Runner) runCagentInContainer(ctx context.Context, imageID, question str
374374
}
375375
}
376376

377+
// Pass additional environment variables specified via -e flag
378+
// Format: KEY or KEY=VALUE
379+
for _, entry := range r.EnvVars {
380+
if key, val, hasValue := strings.Cut(entry, "="); hasValue && key != "" {
381+
args = append(args, "-e", key)
382+
env = append(env, key+"="+val)
383+
} else if val, ok := r.runConfig.EnvProvider().Get(ctx, entry); ok && entry != "" {
384+
args = append(args, "-e", entry)
385+
env = append(env, entry+"="+val)
386+
}
387+
}
388+
377389
args = append(args, imageID, "/configs/"+agentFile, question)
378390

379391
cmd := exec.CommandContext(ctx, "docker", args...)

pkg/evaluation/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ type Config struct {
120120
Only []string // Only run evaluations matching these patterns
121121
BaseImage string // Custom base Docker image for running evaluations
122122
KeepContainers bool // If true, don't remove containers after evaluation (skip --rm)
123+
EnvVars []string // Environment variables to pass: KEY (value from env) or KEY=VALUE (explicit)
123124
}
124125

125126
// Session helper functions

0 commit comments

Comments
 (0)