How faraway1nspace/pedantic-research-assistant-multi-agent works
Project type and purpose
• This is a Python-based multi-agent research assistant built on the Pydantic-AI framework.
• It orchestrates a workflow of specialized LLM agents to perform web searches, document summarization, critique, and report writing for deep research tasks (e.g., company due diligence).
File structure
• Top level
• README.md, requirements.txt, dot_env – project metadata, dependencies, and API key config
• scratch.py, docs/ – demo scripts and documentation
• src/ – application code
• Under src/
• config.py, models.py – shared configuration and Pydantic data models
• utils/webtools.py – helper functions for web fetching, PDF downloads, etc.
• usecase/company_research/
– agents.py – definitions of the five agents (research_assistant_agent, search_intent_agent, summarizer_agent, critic_agent, report_writer_agent)
– config.py, prompts.py, utils.py, models.py – per–use-case configuration, prompt templates, utilities, and data schemas
– main.py – the entry point tying agents together
Key insights from the README
• Agents: each has specialized system prompts and tools
• Tools: deterministic Python functions registered via @agent.tool
• Dependencies: a shared “knowledge base” object passed to each agent for inter-agent communication
• Data validation: using Pydantic models for predictable outputs (e.g., Footnote, ResearchReport)
• External services: OpenAI/Anthropic API for LLM calls, DuckDuckGo (duckduckgo_search) for web search
Main components and interactions
a. Components
• User (CLI or script)
• research_assistant_agent (orchestrator)
• Sub-agents:
• search_intent_agent
• summarizer_agent
• critic_agent
• report_writer_agent
• Tools layer (webtools, PDF downloader, search wrapper)
• Knowledge Base (in-memory store of downloaded docs; a Dependency)
• External services:
• LLM API (OpenAI or Anthropic)
• Web Search API (DuckDuckGo)
• Web / PDF hosts
b. Relationships / Data flow
1. User sends research query → research_assistant_agent
2. research_assistant_agent delegates to search_intent_agent → refines query
3. research_assistant_agent calls webtools → DuckDuckGo API → downloads pages/PDFs → stores them in Knowledge Base
4. research_assistant_agent invokes summarizer_agent on raw docs → summaries returned to KB
5. research_assistant_agent invokes critic_agent → filtered/improved docs in KB
6. research_assistant_agent invokes report_writer_agent → final ResearchReport (with Footnotes) → returned to User
7. All agent→LLM calls go through Pydantic-AI, which wraps OpenAI/Anthropic API
c. Architectural patterns and design principles
• Multi-agent orchestration (modular, specialized workflows)
• Dependency injection (shared Knowledge Base passed via Pydantic-AI Deps)
• Tool registration (functions exposed to agents via decorators)
• Strong typing and validation (Pydantic models for inputs/outputs)
d. Relevant technologies/frameworks
• Python 3.11
• Pydantic-AI (agent framework)
• Pydantic (data models)
• openai / anthropic SDKs
• duckduckgo_search
• dotenv (API key management)