Kagex/Guides
Go SDKAgent Integrations · 5 min read

Build Parallel AI Agent Harnesses with the Kagex Go SDK (pkg/client)

Embed Kagex directly inside custom Go agent orchestrators, eval pipelines, and automated PR fixers with idiomatic context-aware clients for macOS, Linux, and Windows.

Import path
github.com/codewithevilxd/kagex/pkg/client
Example
docs/examples/go-harness/main.go
Concurrency
Native c.Fork(ctx, id, N)
Race candidate bug fixes in parallel forks (Go)
c, _ := client.New(client.Options{Name: "go-harness"})
sb, _ := c.CreateSandbox(ctx, client.CreateSandboxRequest{
  Template:  "auto",
  Workspace: &client.WorkspaceSpec{HostPath: abs, Mode: "sandbox"},
})
defer c.DestroySandbox(context.Background(), sb.ID)

fork, _ := c.Fork(ctx, sb.ID, 2) // 2 parallel CoW sandboxes
// Run tests inside each fork and keep only the passing diff!

Key Engineering Points · 11-Tool MCP Server & One-Command IDE Wiring

All 10 key points →
  • 1sandbox-mcp implements JSON-RPC 2.0 over stdio and bridges seamlessly into sandboxd over Unix domain sockets or loopback TCP.
  • 2sandboxctl mcp install antigravity creates .agents/plugins/kagex/ (or ~/.gemini/config/plugins/kagex/ with --global) containing plugin.json, mcp_config.json, rules/AGENTS.md, and skills/sandbox/SKILL.md.
  • 3sandboxctl mcp install cursor configures .cursor/mcp.json (or ~/.cursor/mcp.json) alongside always-applied .cursor/rules/sandbox.mdc.
  • 4sandboxctl mcp install claude writes .claude/skills/sandbox/SKILL.md and registers the MCP server via claude mcp add with --scope project or --scope user.
  • 5sandboxctl mcp install codex backs up ~/.codex/config.toml to config.toml.bak, appends [mcp_servers.sandbox] (30s startup, 900s tool timeout), and updates AGENTS.md.
  • 6Eleven specialized tools cover full dev workflows: sandbox_exec, sandbox_read_file, sandbox_write_file, sandbox_diff, sandbox_apply, sandbox_pull, sandbox_snapshot, sandbox_network, sandbox_port, sandbox_status, and sandbox_destroy.

Cross-Platform Client Auto-Discovery

pkg/client automatically locates the Unix domain socket on macOS/Linux or reads the Windows loopback endpoint and Bearer token metadata from %LOCALAPPDATA%\sandboxd\ without manual platform branching.

Deterministic Eval & Tree-Search Workflows

Because c.Fork branches a running sandbox via CoW in ~0.8 s, autonomous bug-fixing harnesses can evaluate multiple hypotheses in parallel and apply only verified diffs.

Inspect this architecture live in 3D

Step through MCP ingress, Ghost Secrets, CoW blades, and run sandboxctl commands interactively in your browser.

Frequently Asked Questions

No. pkg/client is pure Go HTTP/JSON over Unix sockets or loopback TCP.