Skip to content

feat(tools): enhance code execution sandbox#66

Merged
Tuanzi1015 merged 1 commit into
MLT-OSS:mainfrom
lml2468:feat/tools-code-exec-sandbox
Apr 11, 2026
Merged

feat(tools): enhance code execution sandbox#66
Tuanzi1015 merged 1 commit into
MLT-OSS:mainfrom
lml2468:feat/tools-code-exec-sandbox

Conversation

@lml2468
Copy link
Copy Markdown
Contributor

@lml2468 lml2468 commented Apr 11, 2026

Summary

  • Add LimitedWriter that wraps bytes.Buffer with streaming output truncation (stdout: 50KB, stderr: 10KB), appending a truncation notice when exceeded
  • Add SandboxConfig with configurable resource limits (MaxStdoutBytes, MaxStderrBytes, MaxToolCalls, Timeout), tool allowlist (default: read_file, write_file, search_files, patch, terminal, web_search, web_extract), and RestrictNetwork flag
  • Add file-based RPC mechanism for tool call forwarding via ~/.hermes/cache/sandbox_rpc/<id>/ with request.json/response.json exchange and allowlist enforcement
  • Add ExecMetrics struct capturing wall time, exit code, stdout/stderr sizes, and tool call count
  • Refactor executePython/executeBash into a shared runSandboxed function using the new sandbox primitives

Test plan

  • LimitedWriter truncation at exact limit, under limit, over limit, and multi-write scenarios
  • SandboxConfig defaults validation and independent copy safety
  • Tool allowlist accept/reject with default, custom, and empty lists
  • RPC processing: no request file, allowlist rejection, max tool calls exceeded, malformed JSON
  • SetupRPCDir/CleanupRPCDir lifecycle
  • ExecMetrics JSON round-trip
  • Full go test ./... -count=1 passes

Fixes #59

Add LimitedWriter for streaming output truncation (stdout: 50KB,
stderr: 10KB), SandboxConfig with resource limits and tool allowlist,
file-based RPC for tool call forwarding, and ExecMetrics for execution
statistics. Refactor executePython/executeBash to share a unified
runSandboxed function that uses the new sandbox primitives.

Fixes MLT-OSS#59
@Tuanzi1015 Tuanzi1015 merged commit 09404e6 into MLT-OSS:main Apr 11, 2026
7 of 8 checks passed
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.

[Feature]: Enhanced code execution sandbox with output limits and tool forwarding

3 participants