Skip to content

fix(code-execution): key remote kernels by tool set - #97265

Closed
Liuzikaii wants to merge 1 commit into
NousResearch:mainfrom
Liuzikaii:fix/97263-remote-kernel-tool-key
Closed

Liuzikaii wants to merge 1 commit into
NousResearch:mainfrom
Liuzikaii:fix/97263-remote-kernel-tool-key

Conversation

@Liuzikaii

Copy link
Copy Markdown
Contributor

Summary

  • include the sorted sandbox tool set in persistent remote-kernel cache keys
  • spawn a fresh kernel and regenerate hermes_tools.py when capabilities change
  • preserve owner-based disposal while matching the local session-kernel key invariant
  • add regression coverage for capability changes on the same owner/environment

Fixes #97263

Testing

  • python -m pytest -p no:cacheprovider tests/tools/test_code_kernel_remote.py tests/tools/test_code_kernel.py -q
  • python -m ruff check tools/code_kernel_remote.py tests/tools/test_code_kernel_remote.py

@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/code-exec execute_code sandbox backend/docker Docker container execution backend/ssh SSH remote execution backend/modal Modal.com cloud execution sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Aug 28, 2026
@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference; please use your judgment.

Overall: Keys remote kernels by tool set to avoid stale stubs.

What it does

  • tools/code_kernel_remote.py:_kernel_key now return (owner,"remote",env_type,task_env_id,tuple(sorted(sandbox_tools))); execute_in_remote_kernel passes sandbox_tools through. Switching from {"read_file"} to {"web_search"} spawns second kernel (len(_REMOTE_KERNELS)==2, two nohup), each with fresh tool stubs instead of reusing prior kernel's read_file stub when web_search needed.

Non-blocking notes

  • tuple(sorted(...)) makes key deterministic irrespective of input order — good.
  • _REMOTE_KERNELS growth now bounded by tool-set permutations; still capped by existing idle_exit reaper and max_session_kernels eviction.

Correct isolation fix, same invariant as local (#94647).

Non-blocking — please use your judgment.

kshitijk4poor pushed a commit that referenced this pull request Sep 5, 2026
…et (#97263)

The hermes_tools stub module a remote kernel imports is generated from sandbox_tools once,
at spawn, but the registry key was (owner, env_type, task_env_id) only: a later
execute_code call with a different tool set (skill loaded, toolset toggled) reused the
kernel and got stale stubs. The tool set is now part of the key; a different set gets
its own kernel and the over-cap eviction keeps the newest.

Salvaged from #97265 by @Liuzikaii.
@kshitijk4poor

Copy link
Copy Markdown
Contributor

Landed on main via #103668 as 7b8cf4c631, with your authorship preserved on the fix commit, @Liuzikaii — thank you. Closing in favour of the merged salvage.

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 backend/ssh SSH remote execution comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state tool/code-exec execute_code sandbox type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remote session kernels reuse stale hermes_tools stubs after capability changes

4 participants