Production Deployment of LangChain DeepAgent Systems

Deploy a production-ready LangChain DeepAgent financial research system utilizing sandboxed filesystem backends, LangGraph CLI servers, and a custom UI frontend.

Jun 19, 20268 min readFollow

Topics You Will Master

Initializing the LangChain DeepAgent class with isolated child sub-agents
Configuring sandboxed filesystem backends using FilesystemBackend virtual modes
Launching the local LangGraph server engine using the LangGraph CLI dev command
Running the React-based frontend web app linked to the active agent backend

For enterprise-grade installations, multi-agent systems must run inside secure environments. LangChain's DeepAgent framework provides built-in delegation structures, context isolation boundaries, and a sandboxed file storage subsystem. By combining this framework with the LangGraph CLI server and a specialized web interface, developers can deploy production-ready researcher assistants.

This guide walks through configuring the DeepAgent framework, setting up secure file backends, and deploying the system.

95% OFF

Agentic RAG with LangChain and LangGraph - Ollama

Step-by-step guide to RAG with LangChain, LangGraph, and Ollama | DeepSeek R1, QWEN, LLAMA, FAISS.

Enroll Now — 95% OFF →

Implementing the Sandboxed DeepAgent

The DeepAgent class structures agent logic by assigning tasks to sandboxed child agents. Each child agent operates with a custom prompt, target tools, and its own context memory.

PYTHON
import os
import sqlite3
from datetime import datetime
from dotenv import load_dotenv
from langchain_google_genai import ChatGoogleGenerativeAI
from langgraph.checkpoint.sqlite import SqliteSaver
from deepagents import create_deep_agent
from deepagents.backends import FilesystemBackend
from scripts.rag_tools import hybrid_search, live_finance_researcher, think_tool
from scripts.deep_prompts import DEEP_RESEARCHER_INSTRUCTIONS, DEEP_ORCHESTRATOR_INSTRUCTIONS

load_dotenv()

# Select the model engine
model = ChatGoogleGenerativeAI(model='gemini-3-pro-preview')

Dynamic Sandboxed File Backends

To prevent agents from accessing or modifying system files outside their assigned workspaces, configure the FilesystemBackend with virtual_mode=True. This locks the agent's file read/write operations inside a specific directory.

PYTHON
RESEARCH_OUTPUT_DIR = os.path.join(os.getcwd(), "research_outputs")

def get_research_backend(user_id: str, thread_id: str) -> FilesystemBackend:
    user_output_dir = os.path.join(RESEARCH_OUTPUT_DIR, user_id, thread_id)
    os.makedirs(user_output_dir, exist_ok=True)
    
    # Configure the filesystem backend sandbox
    backend = FilesystemBackend(
        root_dir=user_output_dir,
        virtual_mode=True  # Locks agent operations inside this folder path
    )
    return backend

Initializing the Orchestrator and Child Sub-Agents

Construct the research sub-agent and attach it to the parent orchestrator:

PYTHON
current_date = datetime.now().strftime("%Y-%m-%d")

# Define the child researcher sub-agent schema
research_sub_agent = {
    "name": "financial-research-agent",
    "description": "Delegate financial research tasks here. Query one target task at a time.",
    "system_prompt": DEEP_RESEARCHER_INSTRUCTIONS.format(date=current_date),
    "tools": [hybrid_search, live_finance_researcher, think_tool]
}

def get_deep_agent(user_id: str, thread_id: str):
    # Setup conversation checkpointer memory
    conn = sqlite3.connect('data/deep_agent_finance_researcher.db', check_same_thread=False)
    checkpointer = SqliteSaver(conn=conn)
    
    # Setup safe sandboxed directory
    backend = get_research_backend(user_id, thread_id)
    
    # Compile the final deep agent
    agent = create_deep_agent(
        model=model,
        tools=[hybrid_search, live_finance_researcher, think_tool],
        system_prompt=DEEP_ORCHESTRATOR_INSTRUCTIONS,
        subagents=[research_sub_agent],
        checkpointer=checkpointer,
        backend=backend
    )
    return agent

When queried, the orchestrator delegates subtasks to the child agent. All output files (such as research_request.md and final_report.md) are saved directly to the user's isolated directory:

PYTHON
from scripts.agent_utils import stream_agent_response

agent = get_deep_agent(user_id="kgptalkie", thread_id="session_1")
stream_agent_response(agent, "What was Amazon's revenue in Q1 2024?", thread_id="session_1")
OUTPUT
Writing research files to: C:\Users\your-username\project\research_outputs\kgptalkie\session_1

  [Tool Triggered]: write_todos
   Arguments: {
     'todos': [
       {'status': 'in_progress', 'content': 'Save research request to /research_request.md'},
       {'status': 'pending', 'content': "Research Amazon's Q1 2024 revenue using a sub-agent"},
       {'status': 'pending', 'content': 'Synthesize findings and write final report to /final_report.md'}
     ]
   }

  [Tool Completed]

Production Deployment Steps

To deploy this multi-agent team in production, run the LangGraph graph executor as an API service, and connect it to a web frontend.

Prerequisites and Software Requirements

Install the required runtimes and command-line tools:

  • uv: Fast Python package installer and manager.
  • Node.js: Version 24 LTS.
  • nvm (or nvm-windows on Windows): Node version manager.
  • Yarn: Version 4 or newer.
  • LangGraph CLI: Version 0.4.11.

Minimum system requirements: 8GB RAM, 10GB disk space, and Python 3.11+.

Target Repositories

Clone the project repositories:

  • Backend: https://github.com/your-username/deep-finance-research
  • Frontend: https://github.com/langchain-ai/deep-agents-ui

Step 1: Deploying the Backend API Server

Navigate to the cloned backend directory and start the LangGraph developer server:

BASH
cd deep-finance-research
langgraph dev
OUTPUT
Running LangGraph API server on http://localhost:2024

This starts the graph server on port 2024 and opens the local LangGraph developer console.

Step 2: Running the Frontend UI Web App

Navigate to the frontend project directory, install dependencies, and start the development server:

BASH
cd deep-agents-ui
yarn install
yarn dev
OUTPUT
Ready on http://localhost:3000

Open http://localhost:3000 in your web browser. In the settings panel, connect the UI to your running backend API at http://localhost:2024.


Setup Resources and Video Guides

For detailed setup walkthroughs across different environments, refer to these step-by-step playlists:


Verifying the Deployment Environment

Verify that all backend engines, package managers, and runtimes are correctly installed:

BASH
uv --version
node --version
yarn --version
langgraph --help
OUTPUT
uv 0.1.5
v24.0.0
4.0.2
Usage: langgraph [OPTIONS] COMMAND [ARGS]...

Found this useful? Keep building with me.

New tutorials every week on YouTube — or go deeper with a full structured course.

Find this tutorial useful?

Subscribe to our YouTube channels for more practical production walk-throughs.

Discussion & Comments