Skip to content

Add claude-agent-sdk example - #21

Draft
opencolin wants to merge 2 commits into
examples/claude-code-sandboxfrom
examples/claude-agent-sdk
Draft

Add claude-agent-sdk example#21
opencolin wants to merge 2 commits into
examples/claude-code-sandboxfrom
examples/claude-agent-sdk

Conversation

@opencolin

@opencolin opencolin commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Anthropic's own agent SDK was the one missing from the Agent frameworks table, beside Vercel AI SDK / LangChain / CrewAI / OpenAI Agents / LlamaIndex / smolagents. This adds it with Tenki as the execution backend.

The integration is tools: [] plus an in-process MCP server. Disabling every built-in tool is the point: left on, the SDK's Bash/Read/Write/Edit run on the machine that called query(), and the sandbox tools would be one option among several. With them off, bash, write_file, and read_file route to sandbox.exec, sandbox.writeFile, and sandbox.readFile, and the agent's entire execution surface is a microVM.

API checked against the installed @anthropic-ai/claude-agent-sdk@0.3.233 typings rather than guessed — tool(name, description, rawZodShape, handler) takes a bare shape (not z.object({...})), createSdkMcpServer({ name, version, tools }) returns an in-process server, and its tools are still namespaced mcp__tenki__* for allowedTools.

Verification

Ran node verify.mjs locally against the live API:

✓ claude-agent-sdk: write_file → bash python3 fib.py → 832040 → read_file → dispose

Exit code 0. It builds the real SDK tool definitions against a live sandbox and calls their handlers directly, no LLM: write_file returns wrote fib.py, bash runs python3 fib.py in the VM and returns exactly 832040, read_file round-trips the script. Real computed values, no truthiness checks.

agent.mjs also ran end to end on Node 24, with a live model turn:

→ mcp__tenki__write_file {"path":"fib.py","content":"def fib(n):\n    a, b = 0, 1\n    for _ in
→ mcp__tenki__bash {"command":"python3 fib.py"}
The 30th Fibonacci number is **832040**.
-rw-r--r-- 1 tenki tenki 136 Aug 17 05:13 fib.py

The agent reached the answer only through the Tenki-backed tools — it had no local ones — and the final ls is agent.mjs proving the artifact exists in the microVM and nowhere on the host.

Behaviours measured live, not assumed

  • A tool handler that throws is caught by the SDK and delivered as an is_error tool result. Drove an agent at a missing path: it saw [not_found] read file failed: ... no such file or directory, reported it, and recovered — so read_file needs no try/catch.
  • A tool result carries no exit status, so a command that fails after writing to stderr reads as success. bash now prefixes exit N on non-zero.

Sequencing

Based on examples/claude-code-sandbox (#20) rather than main, since both PRs add a row to the root README table. Rebased on it again after that PR's latest commit; GitHub will retarget this to main when #20 merges. Review the two commits as one stack, or #20 first.

Adds one row to Agent frameworks; touches nothing else outside examples/claude-agent-sdk/.

claude added 2 commits August 17, 2026 05:16
Anthropic's Claude Agent SDK with a Tenki microVM as its execution backend:
`tools: []` disables every built-in tool, and bash/write_file/read_file are
re-implemented against sandbox.exec, sandbox.writeFile, and sandbox.readFile,
registered through an in-process MCP server.

verify.mjs drives the tool handlers directly with no LLM and asserts a real
computed value (the 30th Fibonacci number, from Python run inside the sandbox).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uz85xGA4zWSge1BtiDNnSN
agent.mjs printed only the final answer, which proved nothing about where
the work ran. It now logs each tool_use as it happens and ends by listing
fib.py inside the sandbox — the file exists in the microVM and nowhere on
the host.

The bash tool discarded the exit status, so a command that failed after
writing to stderr read as success to the model; non-zero exits are now
prefixed with `exit N`.

Also documented, from a live run: a tool handler that throws is delivered
to the agent as an is_error result and it recovers on its own.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uz85xGA4zWSge1BtiDNnSN
@opencolin
opencolin force-pushed the examples/claude-agent-sdk branch from 701cf1f to e61a958 Compare August 17, 2026 05:17
This was referenced Aug 17, 2026
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.

2 participants