[Feature] Pass env / secrets into agent host - #53
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Users had no way to get API keys (OpenAI, Anthropic, embedding models) into an agent container. Add a top-level `env_file` key to global_controller.yaml pointing at a local .env file, which reaches every container as `docker run --env-file`. - resolve_env_file validates the path before anything launches, so a missing .env fails at deploy time instead of deep inside a container. Relative paths resolve against the project root, matching entrypoint. - env_file_args is a context manager owning the local-vs-remote decision and the cleanup, so both runtimes share one code path. Local containers read the original file; remote containers get a copy that is deleted as soon as `docker run` returns, whether or not it succeeded. - GlobalController._push_file streams the file over ssh under `umask 077` rather than scp, so the copy is never briefly world-readable and the secret never lands in a command line. _run_cmd's ssh options moved to a shared _ssh_args. --env-file is appended after the explicit -e VENTIS_* flags; Docker gives those precedence regardless of order, so a stray VENTIS_* line in someone's .env cannot break agent wiring. Closes #50
b8fac01 to
4af43ae
Compare
Two holes in the remote staging path, both found reviewing the feature commit. `umask 077` only governs files the shell creates, and `>` follows symlinks -- so it did not actually guarantee a 0600 copy. The destination path is fully predictable (`/tmp/ventis-env-ventis-ec2-<agent>-<n>`), so a local user on the remote host could pre-create it world-readable, or point it at a file of their own, and collect the API keys. Remove whatever sits at the path before writing; `rm -f` unlinks a symlink rather than following it, so `cat >` then creates a fresh file under the umask. `_run_cmd` joins its argv with spaces and hands the result to a remote shell unquoted. `_push_file` quoted its path but the cleanup `rm` did not, so a container name containing a space split the `rm` into two arguments that matched nothing -- it exited 0 while the secrets file stayed on the host, and the returncode check logged nothing. Scrub the name down to [A-Za-z0-9_.-] in remote_env_path, which also closes the same gap in the `--env-file` argument and in any future use of that path. Still open, tracked separately: a push that dies mid-transfer can leave a copy behind, since the cleanup only covers the `docker run` that follows. On EC2 the instance is terminated on that path, which disposes of it.
| cmd.append(image) | ||
| result = _controller._run_cmd(cmd, host, user=ssh_user) | ||
|
|
||
| # User secrets from `env_file`. Explicit -e flags above still win over |
There was a problem hiding this comment.
What happens if there is not env file ?
There was a problem hiding this comment.
| Env file | Environment | Error handling | Use cases |
|---|---|---|---|
| .env or .local.env | Local | - No env_file (key) in yaml > return None- Has env_file exist but the value is wrong > raise the error | - self-hosted deploy- managed user's local development: Before the user can get onto the platform they has to get it working locally first. So it needs somewhere to store the env key |
| /var/run/ventis/secrets.env | Managed (deployment) | tbd | - Get the user’s env variables from the platform - create this file every project in global controller(must ensure exist and correct) |
Summary:
env_filein the yaml is useless in canyon-managed deployment environments, because it defaults to/var/run/ventis/secrets.env.- as for how to tell whether it’s a canyon-managed deployment environment, just check whether the file at
/var/run/ventis/secrets.envexists.
Remain unclear:
- In UI, there’s no such feature that allow user to pass their keys and how does the secret setup looks like
There was a problem hiding this comment.
I had a deeper evaluation, when we mention this, there should be two environment (canyonos managed deployment and self-host deployment), see the table above
There was a problem hiding this comment.
how to write env_file in yaml? two ways
- skill agent write it, but I will set up a q&a to ask developer's confirmation
- developer write it manually
Many agent projects have their own dependencies, such as OpenAI keys, Anthropic, or even web search tools (tavily). Currently, there isn't a standard way to inject these API keys into a host.
This is dependency for the agent skills adapting into the Ventis format. It has completed end-to-end testing in local docker and works overall.
The main approaches here are:
Closes #50 · CAN-232
Usage