AI agents are hitting a wall with normal tool calling — too many tools, too many round trips, too much of the context window spent on tool descriptions before the agent does anything useful. Code mode is the fix a growing number of teams are converging on, and this episode breaks down what it actually is and how to build it.
Vaibhav is joined by Kyle Mistele (Co-Founder & CTO, HumanLayer), filling in for regular co-host Dex, to unpack code mode from first principles: giving an agent a runtime instead of a list of tools, so it can write code to chain, filter, and compose actions instead of round-tripping the inference API for every step. Kyle walks through HumanLayer's real production implementation — a sandboxed QuickJS runtime with injected bindings that lets an agent safely edit a live Yjs-based rich-text document without ever touching the underlying object directly — and explains why JSON-schema tool interfaces break down once the surface area gets complex.
The second half shifts to Vaibhav's own prototype: a code-mode runtime with the compiler baked in, so dynamically generated agent code gets type-checked against interfaces defined at compile time before it ever executes. They dig into what that buys you (real safety guarantees, near-zero execution overhead, auto-generated UIs from reflection) and what it costs (a genuinely hard sandboxing problem — ban shell, ban reflection, or an agent can steal your API keys). Useful for anyone building agents against complex APIs, working with dozens of MCP tools, or wondering whether their harness should be tool calls or code.
KEY TAKEAWAYS
• Code mode gives an agent a runtime to write and execute code instead of calling tools one at a time — the same idea behind the bash tool, just generalized
• Too many MCP tools (dozens) blows up an agent's context window; code mode with dynamic tool discovery solves this by turning tools into functions the agent calls in code
• JSON schemas break down for complex, well-typed interfaces — agents (and humans) do better writing real code than inventing an ad hoc format on top of JSON
• HumanLayer built a sandboxed QuickJS runtime with injected bindings so agents can edit live Yjs CRDT documents without touching the object directly or round-tripping the inference API mid-edit
• Tool-calling loops can't run "at the speed of code" — network and inference latency puts a hard floor under every round trip that code execution doesn't have
• Baking a compiler into the runtime lets dynamically generated agent code get type-checked against interfaces before it executes — catching bad output before any side effects happen
• The security trade-off is real: untrusted code sharing memory space with your app needs explicit sandboxing (deny-by-default I/O, ban shell and reflection) or an agent can exfiltrate credentials
• Reflection-based tooling can auto-generate UIs and documentation directly from a codebase's function signatures, no extra work required
• Code mode isn't a default — it fits specific shapes of problem: too many tools, complex composable actions, or work that's already well-represented in a language's training distribution
TIMESTAMPS
Cold Open: "The Future of Software Is All Code Mode"
Welcome & Kyle Mistele Intro (filling in for Dex)
What Is Code Mode? Kyle's Definition
Bash: The Simplest Form of Code Mode
The MCP Problem: Too Many Tools, Too Much Context
Why "Dozens" of Tools Is Already Too Many
Live Demo: HumanLayer's Real Code Mode Implementation
The Problem: Letting Agents Edit a Live Rich-Text Document
Why JSON Schemas Break Down for Complex Interfaces
You Can't Execute Tools "At the Speed of Code"
Bindings: The SDK Injected Into the Sandbox
In-Distribution Code vs. Faster Execution: What's the Real Win?
Vaibhav's Vision: Every App Becomes Extensible Software
Live Demo: Compile-Time Type Checking on Generated Code
Enforcing Contracts: "Requires Key Points" or It Fails
Can an Agent Generate a Class That Implements Its Own Behavior?
The Security Question: Stopping Agents From Doing Evil Things
The Sandbox Default: Deny Everything, Then Allow Explicitly
Performance: Compilation in Milliseconds, Near-Zero Execution Cost
Reflection: Auto-Generating UI From Function Signatures
Final Takeaway: When Should You Actually Use Code Mode?
TOPICS COVERED
• AI coding agents
• Code mode
• Tool calling
• MCP (Model Context Protocol)
• Dynamic tool discovery
• Context window management
• JSON schema vs. code
• Sandboxing
• QuickJS
• Yjs / CRDTs
• TypeScript
• Compile-time type checking
• Agent security
• Credential injection
• Reflection
• Dynamic code generation
• Agent harness design
• HumanLayer
• BoundaryML
HASHTAGS
#AIThatWorks #CodeMode #AIAgents #AICoding #SoftwareEngineering #DeveloperTools #AIEngineering #MCP #TypeScript