For translation, open lesson in new tab and use Chrome translate

The Deep Agent Environment

Lesson Video Walkthrough

The video and the text below cover the same material, so pick whichever format you prefer. If they ever differ, the text is the most up-to-date version.

A deep agent runs inside an environment: the place where it can store files, run commands, and optionally execute code inside the agent loop.

Every Deep Agent environment has:

We will look at those three capabilities first, then define the backend layer that implements the filesystem and optional shell. The interpreter is separate from the backend: it is added as its own tool/capability in the agent loop.


File System

LLM read_file · write_file · edit_file ls · grep · glob Backend

The LLM calls standard filesystem tools; the backend determines where the data actually lives.

A filesystem gives the agent a place to work. It can use files as a scratchpad for notes, intermediate results, plans, and generated artifacts.

Deep Agents always provide filesystem tools such as ls, read_file, write_file, edit_file, glob, and grep. The agent sees the same tool surface even if the backend implementation changes.

That backend detail matters when you care where files live, but this lesson only needs the core idea: the filesystem is always part of the environment.


Shell

LLM read_file · write_file · edit_file ls · grep · glob · execute execute("ls -la /workspace") local shell / sandbox $ _

A shell-capable backend adds execute to the filesystem interface.

A shell lets the agent run commands through the execute tool: scripts, tests, package commands, and other process-level work. This is powerful, so the implementation matters.

Different backends can provide different implementations of execute. Two common families are:

Sandbox providers run commands in isolated environments such as containers, VMs, or remote sandboxes. This limits what code can affect compared with running directly on your machine, but safety still depends on sandbox configuration, network access, credentials, and provider isolation.

Local shell runs commands directly on your machine. It has no isolation overhead and can access local resources, but it should be used only when that local access is actually required.

When shell execution is available, the environment backend provides it.


The interpreter

Client LLM Interpreter {} 1 REQUEST 2 CODE BLOCK const results = search(query) const relevant = check(results) createTicket(relevant) ... 3 EVALUATE 4 RETURN FINAL RESULT 5 FINAL RESPONSE

The LLM writes code-like instructions; the interpreter runs them and returns the real result.
The snippet is pseudo-code.

An interpreter works differently from a shell. It runs as a separate tool inside the agent loop and never goes through the backend.

Use an interpreter when the agent needs code-like control flow without starting a full shell process. For example, instead of asking the model to call a tool 100 times, the interpreter can run a loop, collect intermediate results in variables, and return only the final summary to the model.

Why use interpreters?

Most agent work alternates between model reasoning and tool calls. A model can fire several tool calls in one turn, but that batch is fixed the moment it is emitted. Nothing can loop, branch on a result, retry a failure, or feed one call's output into the next without another model turn, and every result returns to the model's context.

Interpreters give the agent a runtime for that work. A loop runs every iteration, intermediate values stay in variables, and only a compact result returns to the model.


Backends

Now that you have seen the environment surface, we can name the implementation layer.

A backend answers questions like:

There is an abstract backend interface with multiple implementations. Some implementations only provide filesystem storage. Some also provide shell execution. Shell execution can be backed by a local shell or by different sandbox providers.

The agent's tool surface can stay the same while the backend changes. The agent can still call read_file or write_file; the backend decides what those calls mean underneath.

The interpreter is not part of this backend layer. It is a separate capability added to the agent loop.


Recap


References

Documentation:

Go deeper: read the source (optional)

The lesson shows how to use this. To see how it's implemented, start with these files:

Go deeper: read the source (optional)

The lesson shows how to use this. To see how it's implemented, start with these files:

Check your understanding

Question: You create a deep agent with no backend and no extra middleware. Which capability is available to the agent without adding anything?
A) An execute tool that runs shell commands in a temporary sandbox
B) An eval tool that runs JavaScript inside the agent loop
C) File tools such as read_file, write_file, and edit_file
D) File tools plus execute, both running on your local machine
Question: Your agent just wrote some code and now needs to run the test suite. What does that depend on?
A) A backend that supports command execution, which adds execute
B) The interpreter, since it can launch any test runner installed locally
C) The file tools, since write_file can run a script after saving it
D) Nothing extra, since every backend exposes an execute tool by default
Question: You swap an agent's backend from one that only stores files to a sandbox backend. Which of these could change?
A) The JavaScript globals that the interpreter can access
B) The model provider the agent sends its requests to
C) The names of the file tools the agent calls
D) Where files live and whether execute is offered
Question: An agent needs to call a lookup tool 100 times and report only a summary. Why might an interpreter help compared with ordinary tool calls?
A) The model can emit many tool calls per turn only with an interpreter on
B) Code can loop over the calls, hold results in variables, and return a summary
C) The interpreter routes each call through the backend, which caches results
D) Each result reaches the model faster, since the interpreter skips ToolMessages