Skip to content

[Feature] Pass env / secrets into agent host - #53

Open
nickhuo wants to merge 4 commits into
mainfrom
jiajunh/can-232-theres-no-mechanism-to-pass-env-secrets-into-the-agent
Open

[Feature] Pass env / secrets into agent host#53
nickhuo wants to merge 4 commits into
mainfrom
jiajunh/can-232-theres-no-mechanism-to-pass-env-secrets-into-the-agent

Conversation

@nickhuo

@nickhuo nickhuo commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

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

inject api key like openai, anthropic, embedding model etc

User need to put their .env to global_controller.yaml, then ventis will:

  1. copy this file as-is to the machine where is going to run the container
  2. when starting the container, add --env-file <file path> (every host will have one copy in the end)
  3. delete the copy that was pushed to the remote machine

Usage

# config/global_controller.yaml
env_file: .env      # relative paths resolve against the project root, like `entrypoint`

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cc507fad-de4b-4604-b43e-1b99068c5003


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nickhuo
nickhuo requested a lite review from Copilot and removed request for Copilot August 26, 2026 05:32
@nickhuo nickhuo changed the title [Feature] Pass env / secrets into agent containers [Feature] Pass env / secrets into agent host Aug 26, 2026
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
@nickhuo
nickhuo force-pushed the jiajunh/can-232-theres-no-mechanism-to-pass-env-secrets-into-the-agent branch from b8fac01 to 4af43ae Compare August 26, 2026 20:25
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if there is not env file ?

@nickhuo nickhuo Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_file in 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.env exists.

Remain unclear:

  • In UI, there’s no such feature that allow user to pass their keys and how does the secret setup looks like

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

There’s no mechanism to pass env / secrets into the agent container

2 participants