Objective
Add a hooks.pre_run field to the AgentV config (both agentv.config.ts and .agentv/config.yaml) that executes a shell command before an eval run starts and injects its exported environment variables into the process.
Users who fetch secrets at runtime (e.g. from Azure Key Vault, AWS Secrets Manager) currently must wrap the agentv CLI in a project-level script. A generic hooks.pre_run config option lets any project inject environment variables from any source by running a shell command, without needing a wrapper.
Design latitude
- New optional
hooks block in config with pre_run field (a shell command string)
- Command runs before the eval starts; stdout is captured and parsed
- Parses
export KEY="value" lines (shell-export format) OR KEY=value lines (dotenv format)
- Injects parsed values into
process.env — only for keys not already set (existing env wins)
- Stderr forwarded to user's stderr for visibility
- Non-zero exit code aborts the eval with a clear error message
- YAML surface:
hooks.pre_run (snake_case); TypeScript surface: hooks.preRun (camelCase)
Acceptance signals
Non-goals
- Supporting multiple pre-run hooks (single command only; use a shell script for composition)
- Post-run hooks (separate concern, separate issue)
- Target-level hooks (this is project-level config only)
Example
# .agentv/config.yaml
hooks:
pre_run: "bun scripts/load-secrets.ts"
// agentv.config.ts
export default defineConfig({
hooks: {
preRun: "bun scripts/load-secrets.ts",
},
});
Objective
Add a
hooks.pre_runfield to the AgentV config (bothagentv.config.tsand.agentv/config.yaml) that executes a shell command before an eval run starts and injects its exported environment variables into the process.Users who fetch secrets at runtime (e.g. from Azure Key Vault, AWS Secrets Manager) currently must wrap the
agentvCLI in a project-level script. A generichooks.pre_runconfig option lets any project inject environment variables from any source by running a shell command, without needing a wrapper.Design latitude
hooksblock in config withpre_runfield (a shell command string)export KEY="value"lines (shell-export format) ORKEY=valuelines (dotenv format)process.env— only for keys not already set (existing env wins)hooks.pre_run(snake_case); TypeScript surface:hooks.preRun(camelCase)Acceptance signals
hooks.pre_run: "bun scripts/load-secrets.ts"in.agentv/config.yamlruns the command before the eval and injects exported env varsdefineConfig({ hooks: { preRun: "bun scripts/load-secrets.ts" } })inagentv.config.tsworks equivalentlyhookscontinue to work unchangedexport KEY="value"andKEY=valueformats)Non-goals
Example