Coding agents need more than a chat window. They need a file browser, a code viewer, and a diff panel, an IDE experience. This pattern connects a deep agent to a sandbox so it can read, write, and execute code in an isolated environment, then exposes the sandbox filesystem through a custom API server so the frontend can display files in real time as the agent works. This page covers the three-panel UI (file tree, code viewer, and chat) and the custom API routes that expose the sandbox filesystem to it. For sandbox providers, lifecycle scoping, seeding files, secrets, deployment, and productionDocumentation Index
Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-cbuipl-1779916257-33d1bcf.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
useStream configuration, see Going to production.
Architecture
This setup has three parts:-
Deep agent with a sandbox backend: The agent gets filesystem tools
(
read_file,write_file,edit_file,execute) automatically from the sandbox -
Custom API server — A FastAPI app exposed via
langgraph.json’shttp.appfield, providing file browsing endpoints the frontend can call - Three-panel frontend: A file tree, code/diff viewer, and chat panel that syncs files in real time as the agent makes changes
Sandbox lifecycle
Choose how long a sandbox lives and who shares it before wiring the frontend. See Sandbox lifecycle for thread-scoped vs assistant-scoped sandboxes, async graph factory setup, TTL behavior, and SDK invocation examples. This guide uses thread-scoped sandboxes by default. The frontend and custom API server both resolve the sandbox from the LangGraph thread ID. That keeps conversations isolated and lets page reloads reconnect to the same environment when you persist the thread ID. For multi-tenant apps, scope sandboxes by user or assistant in your backend factory instead. For demos without LangGraph threads, pass a client-generated session ID in the API URL. The session ID does not persist across browser sessions.Connect the agent and API server
Configure the deep agent with a sandbox backend as described in Execution environment. The agent gets filesystem tools and anexecute tool automatically; no extra
tool configuration is needed.
Building this UI adds one requirement on top of the production setup: a
custom API server which runs outside the agent graph, so both the agent
backend and your file-browsing routes must resolve the same sandbox for
each thread. Store the sandbox ID on thread metadata and share a single
lookup function between them.
Resolve the sandbox from thread metadata
Similar to the example in Going to production, the
agent is an async graph factory invoked on each run. Store the sandbox ID on
thread metadata so custom
http.app routes can call the same
getOrCreateSandboxForThread helper. Going to production uses provider label
lookup instead when the LangGraph SDK is the only entry point.Seed project files
Before the agent runs, upload starter files withuploadFiles /
upload_files. See File transfers
for seeding patterns, provider examples, and syncing
memories or skills into
the sandbox. For LangSmith sandboxes, pass templateName from a
sandbox snapshot when creating the container.
Adding the file browsing API
The agent can read and write files, but the frontend also needs direct access to browse the sandbox filesystem. Add a custom FastAPI API server and expose it through thehttp.app field in langgraph.json.
Create the API server
The sandbox API endpoints use the thread ID as a URL path parameter. This ensures the frontend always accesses the correct sandbox for the current conversation, using the sameget_or_create_sandbox_for_thread function as the
agent’s backend:
Both the agent’s backend and the API server call the same
get_or_create_sandbox_for_thread function. This ensures they always resolveto the same sandbox for a given thread. The sandbox ID in thread metadata
is the single source of truth — no in-memory caches needed.Configure langgraph.json
Register both the agent graph and the API server. The http.app field tells
the LangGraph platform to serve your custom routes alongside the default ones.
See application structure and
LangSmith Deployments
for the full set of langgraph.json options.
langgraph dev, that’s http://localhost:2024.
Custom routes defined in
http.app take priority over default LangGraph routes. This means you
can shadow built-in endpoints if needed, but be careful not to accidentally override routes like
/threads or /runs.Building the frontend
The frontend has three panels: a file tree sidebar, a code/diff viewer, and a chat panel. It usesuseStream for the agent conversation and the custom API
endpoints for file browsing.
For production deployment, point apiUrl at your
LangSmith Deployment, enable
reconnectOnMount and fetchStateHistory, and pass a stable
thread_id on each run. See
Frontend in
Going to production for those settings
and for invoking the agent
with thread_id and runtime context.
Thread creation
Create a LangGraph thread when the page loads and persist its ID insessionStorage so page reloads reconnect to the same sandbox:
File state management
Track two snapshots of the sandbox filesystem: the original state (before the agent runs) and the current state (updated in real time). The thread ID is included in the API URL so requests always hit the correct sandbox:Real-time file sync
The key to the IDE experience is updating files as the agent works, not after it finishes. Watch the stream’s messages forToolMessage instances
from file-mutating tools. When a write_file or edit_file tool call
completes, refresh that specific file. When execute completes, refresh
everything (since a shell command could modify any file):
Detecting changed files
Before each agent run, snapshot the current file contents. After files refresh, compare against the snapshot to identify which files changed:Displaying diffs
Use a framework-appropriate diff library to render unified diffs:| Framework | Library | Component |
|---|---|---|
| React | @pierre/diffs | <FileDiff> with parseDiffFromFile |
| Vue | @git-diff-view/vue | <DiffView> with generateDiffFile from @git-diff-view/file |
| Svelte | @git-diff-view/svelte | <DiffView> with generateDiffFile from @git-diff-view/file |
| Angular | ngx-diff | <ngx-unified-diff> with [before] and [after] |
@pierre/diffs (React):
Changed files summary
Show a summary of all modified files with line-level addition/deletion counts. This gives users a quick overview of the agent’s impact — similar to agit status:
Use cases
A sandbox is the right choice when:- Coding agents that create, modify, and run code need a visual interface beyond chat
- Code review workflows where the agent suggests changes and the user reviews diffs before accepting
- Tutorial or learning apps where an AI assistant helps users build a project step by step, showing changes in context
- Prototyping tools where users describe features in natural language and watch the agent implement them in real time
Best practices
Frontend-specific:- Persist
threadIdinsessionStorageso page reloads reconnect to the same thread and sandbox instead of creating new ones. - Sync files on every relevant tool call, not just when the run finishes. Watch for
write_file,edit_file, andexecutetool messages and refresh immediately. - Default to diff view for changed files. When a user clicks a file that was modified by the agent, show the diff first — that’s what they care about.
- Show compact tool results for read-only operations. Instead of dumping
the full output of
read_filein the chat, show a one-liner likeRead router.js L1-42. Reserve the full output display for mutating tools. - Filter
node_modulesfrom the file tree. Nobody wants to browse thousands of dependency files. Filter them out when fetching the tree.
- Use thread-scoped sandboxes for production apps. See Sandbox lifecycle.
- Share sandbox resolution between the agent backend and the API server via thread metadata so both resolve the same environment with no in-memory caches.
- Seed the sandbox with a real project. See File transfers.
- Keep secrets out of the sandbox. Use the sandbox auth proxy instead of environment variables or file uploads for API keys.
- Add guardrails before launch. Configure rate limits, error handling, and data privacy middleware for autonomous coding agents.
Related
Going to production
Deploy the agent with persistent sandboxes, auth, guardrails, and production
useStream settings.Sandboxes
Sandbox providers, security model, and file transfer APIs.
Frontend overview
Other deep agent UI patterns: subagent streaming, todo lists, and custom state.
Application structure
Full
langgraph.json reference, including custom http.app routes.Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

