dbd910be14f7c526a721f22f249114d9655de949
Deep Search Agent
A minimal implementation of a deep search agent built from scratch using the LangChain framework and OpenAI API.
The agent decides whether to answer a query directly or perform a web search using SerpAPI.
Prerequisites
- Node.js 18+ (ESM support)
- An OpenAI API key
- A SerpAPI key (free tier available)
Setup
# Clone the repository
git clone https://github.com/your-username/deep-search-agent.git
cd deep-search-agent
# Install dependencies
npm install
# Create a .env file with your API keys
cp .env.example .env
# Edit .env and replace the placeholders with your actual keys
Usage
Run the agent with a query:
npm start -- "What is the capital of France?"
The agent will output either a direct answer or the results of a web search.
How It Works
- Planner – Uses an LLM to decide if the query requires a web search or can be answered directly.
- Executor – If a search is needed, the agent calls the SerpAPI tool and returns the results.
- Memory – Stores conversation context (optional for future extensions).
Extending
- Add more tools (e.g., Wikipedia, Calculator) and update the planner prompt accordingly.
- Replace the planner with a more sophisticated planner (e.g., chain of thought).
- Persist memory to a database for long‑term context.
License
MIT License
Languages
Python
80.3%
JavaScript
19.7%