Deep Agent from Scratch

This repository demonstrates a Deep Agent implementation using the LangChain library.
The agent follows the “Deep Agents from Scratch” template and can answer arbitrary questions by leveraging an LLM (OpenAI GPT3.5Turbo by default). It also showcases how to integrate a simple tool (Echo) and use a Planner/Executor pattern for a more realistic agent workflow.

Features

  • Implements the Planner and Executor pattern from the Deep Agents from Scratch template.
  • Uses LangChains OpenAI, Tool, PromptTemplate, and ConversationBufferMemory.
  • Configurable LLM model, temperature, and token limits.
  • Simple commandline interface for quick testing.
  • Environmentvariable based configuration for API keys and model selection.
  • Demonstrates tool integration (Echo tool) and the full agent template.

Prerequisites

  • Node.js 18+ (or any LTS version)
  • An OpenAI API key

Setup

# Clone the repository
git clone https://git.brojs.ru/kuzakhmetovartur/8.-samopisnyy-poiskovyy-agent-na-osnove-
cd 8.-samopisnyy-poiskovyy-agent-na-osnove-

# Install dependencies
npm install

Create a .env file in the project root:

OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-3.5-turbo   # optional, defaults to gpt-3.5-turbo

Tip: Keep your .env file out of version control. Add it to .gitignore if you plan to push the repo.

Usage

Run the agent with a question:

npm start -- "What is the tallest mountain in the world?"

Or simply:

node src/index.js "Your question here"

The agent will output the answer to the console.

Project Structure

├── package.json          # Project metadata and dependencies
├── src/
│   ├── deepAgent.js      # Core DeepAgent implementation (Planner/Executor)
│   └── index.js          # CLI entry point
└── README.md             # Documentation

Extending the Agent

  • Add more sophisticated prompts: Edit the Planner prompt in deepAgent.js.
  • Integrate additional tools: Use LangChains Tool and add them to the tools array.
  • Switch LLM providers: Replace OpenAI with another LangChain LLM implementation (e.g., AzureOpenAI, Anthropic).

License

MIT © 2026


S
Description
BroJS: 8. Самописный поисковый агент на основе deep agents from scratch
Readme MIT 102 KiB
Languages
Python 80.3%
JavaScript 19.7%