Codemode is a harness‑side execution environment that lets an LLM agent orchestrate complex tool interactions without dumping results into the model’s context window. When a tool is called through the usual interface, only the trailing 2000 lines of output are retained in the agent’s context, which quickly becomes a bottleneck for operations that produce large outputs such as image generation or processing extensive datasets. Codemode moves the orchestration layer into the harness itself, creating a clear separation between the agent’s “brain” (the LLM and its context) and the “hands” where tools actually run, thereby allowing the agent to chain multiple steps while keeping the context lightweight.

This image visualizes the core concept of Codemode, where the LLM agent’s context remains lightweight while complex tool orchestration occurs in a harness‑side JavaScript sandbox.
Inside the harness, Codemode runs as a JavaScript sandbox built with QuickJS in a WebAssembly runtime that deliberately disables network access, file system access, timers, and provides only limited RAM. Within these constraints the agent can issue tool calls and receive their full structured outputs, which can be processed programmatically rather than being truncated to text. A store() function lets the agent persist data in the session transcript so that a later Codemode invocation can read it back, enabling stateful workflows such as probing a tool’s response to inspect its shape and then writing a script to process the remaining items. The blog post shows concrete examples: using Codemode to call an image‑generation model via models.getAvailableOfType and models.generateImages, to run sentiment classification on a batch of GitHub issues with the Jev classifier, and to drive a simple game‑debugging loop where Jev decides the next action based on the game state.
Although Codemode unlocks richer agent behavior, it does so under notable trade‑offs. Because the sandbox cannot access the network or filesystem directly, every interaction must go through tool calls to the underlying system, which preserves security but limits what can be done without adding new tools. The choice of JavaScript as the language for Codemode has been noted in discussion, with some observers suggesting that a bash‑based approach might feel more natural for agents already accustomed to command‑line tools; however, JavaScript’s asynchronous features and object manipulation make it well‑suited for the concurrent operations and state‑management patterns that Codemode enables. Additionally, Codemode provides a path to MCP servers: the agent can use tool‑search utilities within the sandbox to discover and invoke services such as the Sentry MCP, showing that the harness‑side scripting layer can also serve as a bridge to external extensibility points.