feat(config): add v5-native env_path/env_from environment injection#1689
Merged
Conversation
Adds explicit .agentv/config.yaml support for env_path (dotenv file
loading) and env_from (argv command output injection), replacing the
ad hoc hooks.before_session shell hook as the supported way to feed
secrets into {{ env.* }} interpolation before validate/eval.
- env_path loads dotenv-style files; missing files warn, don't fail.
- env_from runs argv commands (shell strings rejected) and parses
shell_exports or json stdout into process.env.
- Existing process.env always wins; injected values are never logged.
- hooks.before_session keeps running, now with a deprecation warning,
and config validation no longer flags hooks as an unexpected field.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Deploying agentv with
|
| Latest commit: |
76bdb9a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a7730fe0.agentv.pages.dev |
| Branch Preview URL: | https://feature-v5-env-from-env-path.agentv.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is the v5-native replacement path for
hooks.before_session. It adds explicit.agentv/config.yamlsupport for:env_path: string or array of dotenv-style file paths, loaded before validation/eval so{{ env.* }}references resolve. Relative paths resolve against the project directory (parent of.agentv/). A missing file warns and is skipped.env_from: object or array of{command: [...], format?: 'shell_exports'|'json'}, run before validation/eval.commandmust be a real argv array — shell command strings are rejected.formatdefaults toshell_exports. A failing command aborts the CLI with an error. Output values are never printed to logs.hooks.before_sessionkeeps running for backward compatibility but now logs a deprecation warning, and.agentv/config.yamlschema validation no longer flagshooks/env_path/env_fromas unexpected fields.Why
hooks.before_sessionran an arbitrary shell command string and had no config validation support (agentv validateflaggedhooksas an unexpected field).env_path/env_fromgive an explicit, validated, promptfoo-envPath-inspired contract for the same use case, with argv-only commands (no implicit shell) and secret-safe logging.Notes / known limitations (documented in the docs page)
env_path/env_fromare discovered from the CLI's current working directory at startup, same as legacyhooks.before_session— a nested project's own config only applies when invoked from within that project. Follow-up tracked separately.config.yaml's own fields (e.g.results.repo) are interpolated before that same file'senv_path/env_fromruns, so they can't reference values produced by their ownenv_path/env_from.Test plan
bun testforpackages/core/test/evaluation/env-injection.test.ts(new),config-loader.test.ts,config-validator.test.ts,hooks.test.ts,providers/— all passingbun testforapps/cli/test/unit/preprocess-argv.test.ts,env.test.ts— all passingbun run typecheckfor@agentv/coreandagentv— cleanbiome checkon all changed files — cleanagentv validate .agentv/config.yaml(deprecation warning, no "Unexpected fields"),agentv validate .agentv/targets.yamland an eval file (env-interpolated fields resolve),agentv evalrun against amocktarget confirmingenv_path+env_frominjected values flow through to{{ env.* }}interpolationce-adversarial-reviewer) — found and fixed a P0 (secret fragment could leak into an error message via a malformed JSON parse error) and a P1 (validator treated an emptyenv_path:/env_from:/hooks:YAML key as a hard error while the loader treated it as absent); both fixed with regression tests🤖 Generated with Claude Code