Skip to content

fix(tools): bring file_tools + code_execution container_config to terminal_tool parity#35660

Open
temalo wants to merge 1 commit into
NousResearch:mainfrom
temalo:fix/32848-item6-docker-env-file-codeexec
Open

fix(tools): bring file_tools + code_execution container_config to terminal_tool parity#35660
temalo wants to merge 1 commit into
NousResearch:mainfrom
temalo:fix/32848-item6-docker-env-file-codeexec

Conversation

@temalo

@temalo temalo commented May 31, 2026

Copy link
Copy Markdown
Contributor

Why

tools/terminal_tool.py, tools/file_tools.py, and tools/code_execution_tool.py all build a container_config dict before calling _create_environment(env_type="docker"|"singularity"|"modal"|"daytona", ...). The intent is that all three tools share one container per task and respect the same user-configured docker knobs.

In practice, file_tools and code_execution_tool were each missing several keys that terminal_tool forwards:

Key terminal_tool file_tools (before) code_execution_tool (before)
container_cpu
container_memory
container_disk
container_persistent
modal_mode missing missing
docker_volumes missing
docker_mount_cwd_to_workspace missing
docker_forward_env missing
docker_env missing missing
docker_run_as_host_user
docker_extra_args missing missing
docker_persist_across_processes missing missing
docker_orphan_reaper missing missing

Net effect for users: configure TERMINAL_DOCKER_ENV / TERMINAL_DOCKER_EXTRA_ARGS / a custom modal_mode / etc., and those settings apply to terminal commands but silently disappear for read_file, write_file, patch, search_files, and execute_code. The bug is invisible — no warning, no error, just behavior divergence between three tools that are documented as sharing one environment.

Fixes issue #32848 item 6.

What

Brings the container_config dict in file_tools.py and code_execution_tool.py to parity with terminal_tool.py by adding the missing keys with the same defaults. No behavior change for users who never set those configs (defaults match what terminal_tool already used). For users who did set them, file ops and execute_code now honor them — matching documented intent.

Behaviour change footprint

  • tools/file_tools.py — adds 5 keys to the docker container_config dict (modal_mode, docker_env, docker_extra_args, docker_persist_across_processes, docker_orphan_reaper)
  • tools/code_execution_tool.py — adds 7 keys to the docker container_config dict (the same 5 as above, plus docker_mount_cwd_to_workspace and docker_forward_env)
  • No other production code touched
  • No defaults changed for existing keys
  • No new env vars, no new config schema, no new public API

Test coverage

File New tests What they assert
tests/tools/test_file_tools_container_config.py +11 Each newly-added key forwards correctly when present; each defaults to the documented value when absent; parity-guard test that fails loudly if terminal_tool ever grows a new docker_* knob that file_tools doesn't track
tests/tools/test_code_execution_container_config.py +10 (new file) Same coverage shape as the file_tools test — every key forwarded, defaults verified, parity-guard at the end

All 25 tests pass (21 new + 4 pre-existing in test_file_tools_container_config.py still green).

The parity-guard tests are the important one: they enumerate the canonical docker_* keyset and fail loudly if a future commit adds a knob to terminal_tool without updating the other two. That's the regression class that caused this bug in the first place — locking it down prevents the same drift from recurring.

Out-of-scope (deliberately)

…minal_tool parity

The container_config dict assembled in file_tools._get_file_ops and
code_execution_tool._get_or_create_env was missing several docker_*
keys that terminal_tool forwards to _create_environment. Users who
configured TERMINAL_DOCKER_ENV, TERMINAL_DOCKER_EXTRA_ARGS, custom
modal_mode, or any of the other knobs below saw them apply to terminal
commands but be silently ignored for read_file/write_file/patch/
search_files and execute_code — even though those tools share one
environment per task by design.

Adds the missing keys to both call sites with the same defaults
terminal_tool uses:

  file_tools (5 new keys):       modal_mode, docker_env,
                                  docker_extra_args,
                                  docker_persist_across_processes,
                                  docker_orphan_reaper

  code_execution_tool (7 new):    modal_mode, docker_env,
                                  docker_extra_args,
                                  docker_persist_across_processes,
                                  docker_orphan_reaper,
                                  docker_mount_cwd_to_workspace,
                                  docker_forward_env

No behavior change for users who don't set these configs; defaults
match terminal_tool exactly. No new env vars, no new config schema.

Test coverage:
  - tests/tools/test_file_tools_container_config.py: +11 tests
    (each new key forwarded, each defaults correctly when absent,
    plus a parity-guard test enumerating the canonical docker_* keyset)
  - tests/tools/test_code_execution_container_config.py: NEW file,
    +10 tests covering the same shape

All 25 tests pass. Broader tests/tools/ run shows zero regressions
against pristine upstream/main baseline (same 92 pre-existing
failures both runs, diff empty).

Fixes NousResearch#32848 (item 6 only).
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tools Tool registry, model_tools, toolsets tool/file File tools (read, write, patch, search) tool/code-exec execute_code sandbox tool/terminal Terminal execution and process management backend/docker Docker container execution backend/modal Modal.com cloud execution labels May 31, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This PR supersedes #30097 (execute_code docker_env/forward_env/extra_args parity) — #30097 is a strict subset covering only code_execution_tool, while this PR brings both file_tools and code_execution_tool to full terminal_tool parity.

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

Labels

backend/docker Docker container execution backend/modal Modal.com cloud execution comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists 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.

2 participants