Skip to content

fix: pass docker_forward_env through container_config in all tool paths - #8320

Closed
malaiwah wants to merge 1 commit into
NousResearch:mainfrom
malaiwah:fix/file-tools-docker-config
Closed

malaiwah wants to merge 1 commit into
NousResearch:mainfrom
malaiwah:fix/file-tools-docker-config

Conversation

@malaiwah

@malaiwah malaiwah commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Add docker_forward_env to the container_config dict in three tool entry points that were missing it:

  • tools/terminal_tool.pyterminal_tool() (line ~1272)
  • tools/file_tools.py_get_file_ops() (line ~221)
  • tools/code_execution_tool.py_get_or_create_environment() (line ~483)

Problem

_get_env_config() loads docker_forward_env from TERMINAL_DOCKER_FORWARD_ENV (line 650), and _create_environment() reads it from container_config to pass to the Docker backend (line 717-731). But none of the three callers that build container_config include it — the value is loaded then silently dropped.

Severity: low for stock deployments. The default value is [], so unless a user explicitly sets TERMINAL_DOCKER_FORWARD_ENV (e.g. ["GITHUB_TOKEN", "NPM_TOKEN"]), the missing passthrough has no effect — the default [] in _create_environment() matches the intended empty value.

When it does bite: if a user configures TERMINAL_DOCKER_FORWARD_ENV and the model happens to use write_file or execute_code before terminal in the same turn, those tools create the shared environment first (via _active_environments cache) without forwarding the env vars. The terminal tool then reuses the incomplete environment.

Fix

Add "docker_forward_env": config.get("docker_forward_env", []) to all three container_config dicts, matching what _create_environment() already expects.

Test plan

  • Verified _get_env_config() returns docker_forward_env (line 650)
  • Verified _create_environment() reads it from container_config (line 717)
  • Confirmed all three callers were missing it
  • No existing tests break — default behavior unchanged since [] == []

🤖 Generated with Claude Code

@malaiwah
malaiwah force-pushed the fix/file-tools-docker-config branch from 3b8bb85 to c0f9be6 Compare April 12, 2026 11:06
@malaiwah malaiwah changed the title fix(file_tools): pass full docker config when creating sandbox environment fix: pass docker_forward_env through container_config in all tool paths Apr 12, 2026
Three tool entry points build a container_config dict for
_create_environment() but omit docker_forward_env, which is loaded by
_get_env_config() but never forwarded:

- tools/terminal_tool.py (terminal_tool, line ~1272)
- tools/file_tools.py (_get_file_ops, line ~221)
- tools/code_execution_tool.py (_get_or_create_environment, line ~483)

All three share the same _active_environments cache keyed by task_id.
Whichever tool creates the environment first determines the config for
all subsequent tools in that session. If any of them creates without
docker_forward_env, environment variables like GITHUB_TOKEN are missing
from the sandbox for the entire session.

Add docker_forward_env to container_config in all three locations,
matching what _create_environment() already expects.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@malaiwah
malaiwah force-pushed the fix/file-tools-docker-config branch from c0f9be6 to 8e09afe Compare April 12, 2026 11:22
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have backend/docker Docker container execution comp/tools Tool registry, model_tools, toolsets tool/terminal Terminal execution and process management tool/file File tools (read, write, patch, search) tool/code-exec execute_code sandbox labels Apr 28, 2026
@alt-glitch

Copy link
Copy Markdown

Likely duplicate of #14235 (merged) — that PR already added docker_forward_env/docker_env to container_config.

stevenchanin added a commit to stevenchanin/hermes-agent that referenced this pull request Apr 29, 2026
`_get_or_create_env()` builds the `container_config` dict that's passed
to `_create_environment()`, but it omits `docker_forward_env` and
`docker_env`. Env vars listed in `terminal.docker_forward_env` are
silently dropped when a Docker sandbox is provisioned via `execute_code`,
so credentials-dependent CLIs (himalaya, vercel, gh, firebase, ...) fail
with no-credentials errors even when the agent's whitelist names the
right vars.

The terminal_tool path was fixed in NousResearch#14235 and the file_tools path in
NousResearch#12900. PR NousResearch#8320 originally fixed all three in one diff but went DIRTY
once the other two merged independently and was incorrectly closed as a
duplicate of NousResearch#14235 — the code_execution_tool chunk is still needed.

Closes NousResearch#12534. Refs NousResearch#5722, NousResearch#16214, NousResearch#8320.

Note: the docker_env config-bridging in cli.py (NousResearch#16214) is orthogonal
and still required for terminal.docker_env values to actually reach
_get_env_config(). Including the key here keeps shape parity with
terminal_tool.py so wiring is in place once that fix lands.
@benbarclay benbarclay closed this May 18, 2026
@benbarclay

Copy link
Copy Markdown
Contributor

Fixed in #14235

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

Labels

backend/docker Docker container execution comp/tools Tool registry, model_tools, toolsets P3 Low — cosmetic, nice to have tool/code-exec execute_code sandbox tool/file File tools (read, write, patch, search) tool/terminal Terminal execution and process management type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants