This repository is a reference implementation of a stateful Plan-Execute Research Assistant built on LangGraph. It implements a Tri-Model Adversarial Architecture (using OpenAI, Anthropic, and Google Vertex AI) to autonomously investigate complex queries, evaluate sources, debate claims from opposing viewpoints, and compile synthesis verdicts.
To visualize, debug, and trace the dynamic cyclical graphs of this system, the project features a Web Dashboard UI and includes demo integrations with the OrchidTrace proxy debugger for both Python and TypeScript execution layers.
Before running either standalone demo, ensure you have the OrchidTrace proxy installed and running in the background.
docker run -d \
--name orchid-proxy \
-p 4320:4320 \
-p 4321:4321 \
-v orchid-data:/data \
-e ORCHID_API_KEY=your_proxy_api_key_here \
-e ORCHID_DB_PATH=/data/orchid.db \
ghcr.io/mario-guerra/orchid-proxy:latestPlays back a recorded execution path completely offline from the included Python fixture. No external API keys or credentials needed.
- Import the Included Python Demo Fixture into the proxy:
curl -X POST http://localhost:4321/v1/sessions/import \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_proxy_api_key_here" \ -d @orchid_langgraph_demo_fixture_python.json
- Configure your Local Environment:
Create a
.envfile in the project root:ORCHID_API_KEY=your_proxy_api_key_here ORCHID_MODE=replay ORCHID_SESSION_ID="Orchid LangGraph Demo"
- Initialize and Activate Virtual Environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate pip install -r requirements.txt
- Run the Playback:
python -m py_agent.orchid_demo
- View the Traces: Open
http://localhost:4321in your browser, log in with your API key, and inspect the session"Orchid LangGraph Demo".
To run the Python multi-agent system live, query real LLMs, and record your own custom trace session:
- Set Up Upstream Credentials in the root
.envfile:SERPAPI_API_KEY=your_serpapi_key_here OPENAI_API_KEY=your_openai_key_here ANTHROPIC_API_KEY=your_anthropic_key_here ORCHID_API_KEY=your_proxy_api_key_here
- Authenticate with Google Cloud (for Vertex AI):
gcloud auth application-default login
- Run the Demo:
Ensure
ORCHID_MODEis NOT set toreplayin.env(or set it tocapture), then:python -m py_agent.orchid_demo
Plays back a recorded execution path completely offline from the included TypeScript fixture. No external API keys or credentials needed.
- Import the Included TypeScript Demo Fixture into the proxy:
curl -X POST http://localhost:4321/v1/sessions/import \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_proxy_api_key_here" \ -d @orchid_langgraph_demo_fixture_typescript.json
- Configure your Local Environment:
Create a
.envfile inside thets_agent/directory:ORCHID_API_KEY=your_proxy_api_key_here ORCHID_MODE=replay ORCHID_SESSION_ID="Orchid LangGraph Demo - TypeScript"
- Install Dependencies:
cd ts_agent npm install - Run the Playback:
npm run demo
- View the Traces: Open
http://localhost:4321in your browser, log in with your API key, and inspect the session"Orchid LangGraph Demo - TypeScript".
To run the TypeScript multi-agent system live, query real LLMs, and record your own custom trace session:
- Set Up Upstream Credentials in
ts_agent/.env:GOOGLE_API_KEY=your_google_key_here OPENAI_API_KEY=your_openai_key_here ANTHROPIC_API_KEY=your_anthropic_key_here SERPAPI_API_KEY=your_serpapi_key_here ORCHID_API_KEY=your_proxy_api_key_here
- Authenticate with Google Cloud (for Vertex AI):
gcloud auth application-default login
- Run the Demo:
Ensure
ORCHID_MODEis NOT set toreplayints_agent/.env, then:npm run demo
Run the full adversarial research multi-agent system inside a web interface. Watch the agent engine's live query expansion, evidence analysis, source credibility checks, and debate loops in real-time.
- Activate your Python Virtual Environment:
source .venv/bin/activate - Start the FastAPI Development Server:
uvicorn web.server:app --reload --port 8000
- Open the Dashboard:
Navigate to
http://localhost:8000in your web browser.
- Unified Chronological Flow Map: A centered, auto-scrolling graph mapping the step-by-step agent lifecycle from query parsing to synthesis judge.
- Dynamic Text Scaling Controls: Use the
Aβ,A, andA+buttons in the global header to scale the dashboard typography dynamically to your liking (saved and persisted vialocalStorage). - Markdown Tables Compiler: Native compiler for complex LLM synthesis data, rendering tables with clean, glassmorphic styles and interactive citation highlights.
- Historical Run Manager: Inspect past research sessions synced dynamically via Server-Sent Events, or delete old sessions directly from the sidebar.
Unlike traditional DAGs, this system uses a dynamic, cyclical Plan-Execute architecture. The graph routes intelligently based on the LLM's own uncertainty and evaluation signals. OrchidTrace is used to debug these dynamic routing decisions.
graph TD
classDef llmNode fill:#4c1d95,stroke:#8b5cf6,stroke-width:2px,color:#ffffff,rx:8px,ry:8px;
A["User Input"] --> B["Intent Parser (LLM)"]:::llmNode
B --> C{"Ambiguous?"}
C -->|Yes| D["Clarification Node (LLM)"]:::llmNode
D -.->|"User Input"| B
C -->|No| E["Planner Node (LLM)"]:::llmNode
E --> F["Executor: Run Tool"]
F --> G["Step Evaluator (LLM)"]:::llmNode
G -->|Retry| F
G -->|Accept| H["Evidence Evaluator (LLM)"]:::llmNode
H --> I{"Sufficient?"}
I -->|Augment| F
I -->|Proceed| J["Credibility Scorer (LLM)"]:::llmNode
J --> K["Debate: Optimist (LLM)"]:::llmNode
K --> L["Debate: Skeptic (LLM)"]:::llmNode
L --> M["Judge (LLM)"]:::llmNode
M --> N["Final Answer"]
langgraph_example/
βββ py_agent/ # Python implementation of the Adversarial Research Agent
β βββ __init__.py # Exposes create_research_graph
β βββ agents.py # Intent, Clarification, Executor, and Evaluator nodes
β βββ config.py # Configuration and API key setup
β βββ credibility.py # Source credibility scoring engine
β βββ debate.py # Optimist, Skeptic, and Judge nodes
β βββ graph.py # StateGraph definition and routing logic
β βββ llm.py # Centralized Vertex AI model initialization
β βββ planner.py # Autonomous research planning node
β βββ schemas.py # Pydantic models enforcing structured output validation
β βββ state.py # AgentState definitions
β βββ tools.py # Tool registry (SerpAPI web, news, weather search)
β βββ utils.py # LLM structured output query and validation helpers
β βββ main.py # Interactive CLI with real-time state streaming (Python)
β βββ orchid_demo.py # Automated integration tests with Orchid capture mode enabled (Python)
βββ ts_agent/ # TypeScript port of the agent system with Orchid integration
β βββ src/
β β βββ agents.ts # Graph nodes and routing functions
β β βββ credibility.ts # Credibility scorer node
β β βββ demo.ts # CLI runner with Orchid SDK initialization
β β βββ graph.ts # StateGraph construction
β β βββ llm.ts # LLM declarations (Gemini, o3-mini, Claude)
β β βββ schemas.ts # Zod models for structured output validation
β β βββ state.ts # Reducers and state annotation definitions
β β βββ tools.ts # Query tool implementations
β β βββ utils.ts # Retry helpers and validation correction
β βββ package.json # Project dependencies
β βββ tsconfig.json # TypeScript configuration
βββ web/ # Interactive Dashboard Web Server
β βββ .sessions/ # Persistent storage for historical run JSON logs
β βββ static/ # Frontend Dashboard client assets (HTML, CSS, JS)
β βββ server.py # FastAPI server serving API, static UI, and SSE streams
βββ tests/ # Integration tests for server endpoints
βββ web_ui.png # Web UI Screenshot
- Python 3.11+ (for Python implementation)
- Node.js 18+ (for TypeScript implementation)
- Google Cloud Platform account (with Vertex AI enabled)
gcloudCLI installed and authenticated- SerpAPI key
- OpenAI API key
- Anthropic API key
- Vertex AI: We use
langchain-google-vertexai/@langchain/google-vertexai. Ensure you have authenticated locally viagcloud auth application-default loginand set your quota project. - SerpAPI, LLMs, & Orchid Proxy: Create a
.envfile (and/orts_agent/.env) and add:SERPAPI_API_KEY=your_key_here OPENAI_API_KEY=your_openai_key_here ANTHROPIC_API_KEY=your_anthropic_key_here ORCHID_API_KEY=your_proxy_api_key_here
- Unauthorized: 401 POST http://127.0.0.1:4320: The Orchid proxy runs in secure mode and requires an API key to accept requests. Ensure
ORCHID_API_KEYis set in your.envfile. - ModuleNotFoundError / Cannot find module: Ensure you have run
pip install -r requirements.txt(Python) ornpm installinsidets_agent/(TypeScript). - 429 RESOURCE_EXHAUSTED / NOT_FOUND: This indicates a Google API issue. Ensure you are authenticated via
gcloud auth application-default login. - Missing SerpAPI Key: The Executor will safely catch the missing key and return an error string, but no actual research will occur. Add it to your
.env.
MIT License β Free for learning, refactoring, and agentic experimentation.
