2026-06-05 11:04:54 +00:00
2026-06-04 19:19:46 +00:00
2026-06-04 19:18:51 +00:00
2026-06-04 19:18:57 +00:00
2026-06-02 07:03:41 +00:00
2026-06-04 19:19:09 +00:00
2026-06-05 10:31:14 +00:00
2026-06-05 10:31:19 +00:00
2026-06-04 19:19:28 +00:00
2026-06-04 19:19:34 +00:00
2026-06-04 19:19:40 +00:00

Deep Agent with StateGraph

This repository contains a minimal implementation of a Deep Agent based on the deep-agents-from-scratch notebook. The agent uses a LangGraph StateGraph to orchestrate the following steps:

  1. Think decide what to search for.
  2. Search perform a web search with Tavily.
  3. Summarize summarize each search result and store the raw content in a virtual file system.
  4. Write File dump all virtual files to disk.

The implementation follows the modern LangChain API guidelines:

  • All imports use the current modular packages (langchain_openai, langgraph, langchain_core, etc.).
  • No legacy langchain.chat_models or langchain.llms imports.
  • The agent can be run from the command line.

Setup

# Create a virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Run the agent interactively
python src/deep_agents_from_scratch/deep_agent.py

Usage

After starting the script you will be prompted to enter a research question. The agent will perform a web search, summarize the results, and write the raw content to the output/ directory.

Project Structure

src/
├── deep_agents_from_scratch/
│   ├── __init__.py
│   ├── deep_agent.py
│   ├── research_tools.py
│   └── state.py
  • state.py defines the DeepAgentState dataclass used by the graph.
  • research_tools.py contains the Tavily search, think, and summarization tools.
  • deep_agent.py builds the StateGraph, defines node functions, and provides a CLI entry point.

Extending the Agent

You can add more tools or nodes by following the pattern used in deep_agent.py. For example, to add a node that writes the summaries to a PDF you would:

  1. Create a new tool that formats the summaries.
  2. Add a node function that calls the tool.
  3. Connect the node in the graph.

License

MIT License.

S
Description
8. Самописный поисковый агент на основе deep agents from scratch
Readme MIT 133 KiB
Languages
Python 100%