Skip to content

feat: Pluggable agent sandbox/workspace#1499

Draft
EItanya wants to merge 9 commits intomainfrom
eitanya/filesystem
Draft

feat: Pluggable agent sandbox/workspace#1499
EItanya wants to merge 9 commits intomainfrom
eitanya/filesystem

Conversation

@EItanya
Copy link
Contributor

@EItanya EItanya commented Mar 13, 2026

Summary

Adds per-session sandbox/workspace provisioning for agents using the kubernetes-sigs/agent-sandbox project. When an agent has workspace.enabled: true, the system automatically provisions an isolated sandbox pod (filesystem + shell) for each conversation session, giving the agent secure exec and file tools.

Key changes

  • CRD: New workspace field on AgentSpec.Declarative with enabled (bool) and optional templateRef (string) to reference a custom SandboxTemplate
  • Controller sandbox provider (go/core/internal/controller/sandbox/): Pluggable SandboxProvider interface with AgentSandboxProvider implementation that creates/manages SandboxClaim resources and polls until the sandbox is ready, returning the MCP endpoint URL
  • Sandbox template plugin (sandbox_template_plugin.go): Auto-generates a SandboxTemplate CR for workspace-enabled agents during reconciliation, embedding the sandbox-mcp sidecar container with configurable image registry/repository/tag
  • HTTP sandbox handler (handlers/sandbox.go): POST /api/sessions/{id}/sandbox endpoint that resolves the agent's workspace config, determines the template name, and calls the provider to provision/return a sandbox
  • Python ADK (_agent_executor.py): _ensure_sandbox_toolset() provisions the sandbox on first request for a session, stores the MCP URL in session state, and dynamically appends sandbox tools to the runner
  • Go ADK (go/adk/pkg/sandbox/): Sandbox provisioner, registry, and toolset packages for Go-based agents
  • sandbox-mcp server (go/sandbox-mcp/): Streamlined Go MCP server providing exec, write_file, read_file, list_dir tools plus a skills system, with simplified Dockerfile
  • Helm: agentSandbox.enabled value (default false), configmap env vars for sandbox image config, RBAC for SandboxClaim/SandboxTemplate resources
  • Makefile: Removed buildx cache (--cache-from/--cache-to) for reliable dirty-tree builds

How it works

  1. User sets workspace.enabled: true on an Agent CR
  2. Controller reconciles → auto-generates a SandboxTemplate with the sandbox-mcp sidecar
  3. On first message to the agent, the ADK calls POST /api/sessions/{id}/sandbox
  4. Controller creates a SandboxClaim → agent-sandbox provisions an isolated pod
  5. Handler polls until ready, returns the sandbox-mcp MCP endpoint URL
  6. ADK adds sandbox tools (exec, write_file, read_file, list_dir) to the agent's toolset
  7. Agent can now execute commands and manipulate files in the isolated sandbox
  8. Sandbox is cleaned up when the session is deleted

Test plan

  • Unit tests for sandbox provider, template plugin, registry, toolset, skills, exec, and fs tools
  • make -C go test passes (all unit tests green)
  • E2E: Deployed with agentSandbox.enabled=true, created agent with workspace.enabled: true, invoked via CLI — agent successfully used write_file and exec tools in provisioned sandbox

🤖 Generated with Claude Code

Comment left by Claude on behalf of @EItanya

EItanya and others added 9 commits March 12, 2026 19:04
Implements phases 1-5 of the pluggable sandbox design:

- Phase 1: Add workspace field to Agent CRD, thread through config.json
  to agent pod via translator, add Python WorkspaceConfig type
- Phase 2: SandboxProvider interface, SandboxManager with goroutine-safe
  session-to-sandbox lifecycle mapping, stub provider for testing
- Phase 3: POST/GET /api/sessions/{id}/sandbox HTTP endpoints, sandbox
  cleanup on session delete, wiring through ServerConfig and app startup
- Phase 4: Python ADK sandbox provisioning on session start, stores MCP
  URL in session state, dynamically adds KAgentMcpToolset to runner
- Phase 5: kagent-sandbox-mcp container image with exec, read_file,
  write_file, list_dir MCP tools over StreamableHTTP

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Aligns with the database.Client API change from main that added
context.Context as the first parameter to all database methods.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
…x-mcp logging

Replace the in-memory SandboxManager with AgentSandboxProvider that uses
kubernetes-sigs/agent-sandbox SandboxClaim CRDs. GetOrCreate now blocks
using wait.PollUntilContextCancel until the sandbox is ready, a terminal
failure is detected, or the context expires. NotFound errors during polling
are treated as transient (cache sync delay).

Also adds structured logging to sandbox-mcp tool handlers, switches the
sandbox-mcp Dockerfile to python:3.13-slim (exec tool needs a shell),
and includes Helm RBAC templates for kagent-controller to access sandbox CRDs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
…ox-mcp improvements

Add per-session sandbox provisioning for workspace-enabled agents, remove
buildx caching from Makefile for reliable dirty-tree builds, and improve
sandbox-mcp with skills support and streamlined Dockerfile.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Move from docs/design/ to docs/architecture/ and update to reflect
the actual implementation rather than the original design proposal.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Fix gofmt alignment in registry_test.go and use apierrors alias for
k8s.io/apimachinery/pkg/api/errors per project linter config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
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.

1 participant