4be7a21036a4f404430138aea46faa953ad5f87a
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 GPT‑3.5‑Turbo 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 LangChain’s
OpenAI,Tool,PromptTemplate, andConversationBufferMemory. - Configurable LLM model, temperature, and token limits.
- Simple command‑line interface for quick testing.
- Environment‑variable 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
.envfile out of version control. Add it to.gitignoreif 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
Plannerprompt indeepAgent.js. - Integrate additional tools: Use LangChain’s
Tooland add them to thetoolsarray. - Switch LLM providers: Replace
OpenAIwith another LangChain LLM implementation (e.g.,AzureOpenAI,Anthropic).
License
MIT © 2026
Languages
Python
80.3%
JavaScript
19.7%