How raianrashidrimon/research-ai-agent works
1. Overall shape
- This repo is a single Python application organized around a serial multi-agent research pipeline.
- The architectural center is: User query → Researcher → Writer → Fact Checker → final answer.
- The code is split into small boundaries for orchestration, agent behavior, external tools, persistence, and presentation.
2. Primary package boundary
- The Agent/ directory is the application package.
- Agent/agents/ holds the three specialized agent implementations.
- Agent/graph.py appears to be the workflow coordinator.
- Agent/tools.py, Agent/memory.py, Agent/ui.py, and Agent/main.py are supporting subsystems around that core pipeline.
3. Workflow orchestration
- graph.py is the key architectural component for agent coordination.
- It likely defines the execution order and message passing between the Researcher, Writer, and Fact Checker.
- This is the place where the “serial pipeline” described in the README is enforced, rather than letting agents run independently.
4. Agent responsibilities
- agents/researcher.py gathers raw material from external sources.
- agents/writer.py converts raw findings into a readable summary.
- agents/fact_checker.py verifies claims, flags uncertainty, and assigns a confidence level.
- agents/__init__.py exposes these roles as a cohesive subpackage.
5. External data acquisition boundary
- tools.py is the integration layer for external knowledge sources.
- The README says it uses DuckDuckGo Search, Wikipedia, and ArXiv, so this module is the main boundary between the app and the outside world.
- This is also where the architecture depends on network access and third-party search/content services.
6. Memory and persistence
- memory.py provides cross-session memory, which is an important stateful subsystem in an otherwise query-driven workflow.
- The README indicates the assistant “remembers what it has researched before,” so memory is not just in-request context; it persists across restarts.
- This creates a second data path besides live search: prior research is loaded and reused when relevant.
7. Presentation layer
- ui.py is the Streamlit-based chat UI.
- The UI likely submits the user query into the pipeline, then renders the final summary plus supporting artifacts.
- The README specifically mentions a sidebar for sources and flagged claims, so the UI is not just a text box; it visualizes provenance and verification status.
8. Terminal entrypoint
- main.py is the non-UI entrypoint for running the assistant from the terminal.
- This suggests two operating modes that share the same core workflow: CLI/terminal and Streamlit.
- For an architecture diagram, both entrypoints should converge into the same orchestration layer, not duplicate the agent logic.
9. LLM and framework dependencies
- The repo uses Google Gemini as the model provider, via a .env-supplied GEMINI_API_KEY.
- The README also names LangGraph and LangChain, so the agent pipeline is framework-driven rather than hand-rolled.
- These are enabling technologies for orchestration and tool use, but the important architectural fact is that the app is model-backed and tool-augmented.
10. Output and trust model
- The fact checker produces a confidence score: HIGH, MEDIUM, or LOW.
- It also flags uncertain or unverified claims, which means the final output is not just summarized text but a response annotated with trust signals.
- This makes the system a research assistant with a verification layer, not a pure summarizer.
11. Report persistence
- The README says reports can be saved to a local text file.
- That implies a simple file-based output path for exporting the final research result outside the UI/session.
- This is likely a lightweight persistence/output feature, separate from the long-term memory store.
12. End-to-end data flow
- The main flow is: user query enters via Streamlit or terminal, the orchestrator dispatches to the Researcher, raw sources are summarized by the Writer, the Fact Checker validates the claims, and the final annotated answer is returned.
- Along the way, source references and memory state are carried through the system.
- For an architecture diagram, the most important boundaries are: entrypoints, agent orchestration, external search tools, persistent memory, and presentation/output.
Main entry points: fact_checker.py Fact checker · graph.py Workflow graph · tools.py Search tools · researcher.py Researcher
Components 15
Agent package
Core application package containing orchestration, agents, entrypoints, and support subsystems.
- Streamlit UI · Chat interface for submitting queries and viewing sources and flags.
Agent/ui.py - Terminal app · Command-line entrypoint for running the assistant without the UI.
Agent/main.py - Workflow graph · Coordinates the serial research pipeline and message passing between agents.
Agent/graph.py - Researcher · Collects raw evidence from external sources and prior context.
Agent/agents/researcher.py - Writer · Turns research findings into a readable draft summary.
Agent/agents/writer.py - Fact checker · Verifies claims, flags uncertainty, and assigns confidence.
Agent/agents/fact_checker.py - Agents API · Exports the agent roles as a cohesive package boundary.
Agent/agents/__init__.py - Search tools · Tooling layer for external knowledge sources and retrieval.
Agent/tools.py - Memory store · Cross-session research memory reused across runs.
Agent/memory.py - Saved report · Local text-file output for persisted research reports.
External systems
Model provider and knowledge sources used by the application.
- Gemini model · LLM backend used for generation and verification tasks.
- DuckDuckGo · Web search source used by the research agent.
- Wikipedia · Reference source used during research.
- ArXiv · Scientific paper source used during research.
Other components
- User query · Incoming research question or prompt.
Connections 21
- User query → Streamlit UI: submit · User enters a question through the Streamlit interface.
- User query → Terminal app: run · User passes a question through the terminal entrypoint.
- Streamlit UI → Workflow graph: dispatch · UI forwards the request into the shared workflow.
- Terminal app → Workflow graph: dispatch · CLI forwards the request into the shared workflow.
- Workflow graph → Researcher: step 1 · Orchestrator sends the query to the research agent.
- Researcher → Search tools: retrieve · Researcher uses tools to gather evidence.
- Search tools → DuckDuckGo: search · Tooling queries web search.
- Search tools → Wikipedia: lookup · Tooling pulls reference material from Wikipedia.
- Search tools → ArXiv: search · Tooling searches academic papers.
- Researcher → Memory store: reuse · Researcher consults prior research memory.
- Workflow graph → Writer: step 2 · Orchestrator passes research findings to the writer.
- Writer → Gemini model: generate · Writer uses the model to compose the summary.
- Workflow graph → Fact checker: step 3 · Orchestrator sends the draft to fact checking.
- Fact checker → Gemini model: verify · Fact checker uses the model to assess claims and confidence.
- Fact checker → Memory store: update · Verified research can be stored for later reuse.
- Fact checker → Streamlit UI: return · Final annotated answer is rendered in the chat UI.
- Fact checker → Terminal app: return · Final annotated answer is printed or returned in terminal mode.
- Fact checker → Saved report: save · Reports can be exported to a local text file.
- Agents API → Researcher: expose · Package exports the researcher role.
- Agents API → Writer: expose · Package exports the writer role.
- Agents API → Fact checker: expose · Package exports the fact-checker role.