How jeongeunyeom/petroleum-rag-agent works
Petroleum Engineering AI Agent is a local-first research and calculation product centered on a single chat input. A message becomes a goal run, which retrieves internal evidence by default and conditionally calculates, simulates, analyzes, and verifies before returning cited results or requesting clarification; completed runs can produce reports. Separate documented capabilities include evidence-based Research, document ingestion and Q&A, figure review, and a constrained workspace agent. Edges reflect README workflows and source-index references; several feature branches have directory-level paths because their implementation was not sampled.
Main entry points: goal_execution_agent.py Goal controller · goal_research_routes.py Goal run API · goal_research_agent.py Goal researcher · routes.py Core API
Components 28
Chat experience
- Chat UI
frontend/app/page.tsx - Goal results
frontend/components/GoalResearchPanel.tsx - Citation display
frontend/components/DocumentInfoPanel.tsx
API and orchestration
- Goal run API
backend/app/api/goal_research_routes.py - Research API
backend/app/api/research_routes.py - Core API
backend/app/api/routes.py
Research and evidence
- Evidence research
backend/app/services/research_agent.py - Knowledge Q&A
backend/app/services/qa.py - Knowledge store
backend/app/services/vector_store.py - Web research
backend/app/services/web_research.py - Engineering checks
backend/app/services/engineering_validator.py - Document ingestion
backend/app/services/document_processor.py - Figure review
backend/app/services/figure_review.py
Goal execution
- Run lifecycle
backend/app/services/goal_research_service.py - Message parsing
backend/app/services/goal_message_parser.py - Goal controller
backend/app/services/goal_execution_agent.py - Goal researcher
backend/app/services/goal_research_agent.py - Action planner
backend/app/services/goal_tool_planner.py - Goal evaluator
backend/app/services/goal_evaluator.py - Calc requirements
backend/app/services/calculation_requirements.py - Claim grounding
backend/app/services/calc_claim_grounding.py - User fact registry
backend/app/services/user_fact_registry.py
Agents and deliverables
- Python sandbox
backend/app/tools/python_tools.py - Tool permissions
backend/app/agents/permission_manager.py - Report generation
backend/app/services/deliverables/service.py
Other components
- Researcher
- Ollama models
- DDGS search
Connections 29
- Researcher → Chat UI: submits goal
- Chat UI → Goal run API: starts run
- Goal run API → Message parsing: parses message
backend/app/api/goal_research_routes.py - Goal run API → Run lifecycle: starts run
backend/app/api/goal_research_routes.py - Run lifecycle → Goal controller: runs controller
backend/app/services/goal_research_service.py - Goal controller → Goal researcher: researches goal
backend/app/services/goal_execution_agent.py - Goal controller → Action planner: plans actions
backend/app/services/goal_execution_agent.py - Goal controller → Goal evaluator: evaluates outcome
backend/app/services/goal_execution_agent.py - Goal controller → Calc requirements: checks inputs
backend/app/services/goal_execution_agent.py - Goal controller → Claim grounding: grounds claims
backend/app/services/goal_execution_agent.py - Goal controller → User fact registry: tracks user facts
backend/app/services/goal_execution_agent.py - Goal researcher → Evidence research: gathers evidence
backend/app/services/goal_research_agent.py - Evidence research → Knowledge store: retrieves evidence
- Goal researcher → Web research: searches when requested
- Web research → DDGS search: discovers sources
- Goal researcher → Engineering checks: checks claims
- Goal controller → Python sandbox: runs calculations
- Goal controller → Ollama models: uses language model
- Run lifecycle → Report generation: creates deliverables
backend/app/services/goal_research_service.py - Goal run API → Goal results: returns run results
- Goal results → Citation display: shows citations
- Researcher → Research API: requests evidence
- Research API → Evidence research: dispatches research
backend/app/api/research_routes.py - Core API → Knowledge Q&A: answers questions
backend/app/api/routes.py - Knowledge Q&A → Knowledge store: retrieves context
- Core API → Document ingestion: processes uploads
backend/app/api/routes.py - Researcher → Figure review: opens figure review
- Core API → Figure review: serves review API
backend/app/api/routes.py - Tool permissions → Python sandbox: authorizes tool use
backend/app/agents/permission_manager.py