Skip to content

Add GPT API-based multi-agent system for automated ERT workflows - #3

Merged
geohang merged 5 commits into
mainfrom
copilot/create-multiple-agents-for-processing
Nov 6, 2025
Merged

geohang merged 5 commits into
mainfrom
copilot/create-multiple-agents-for-processing

Conversation

Copilot AI commented Nov 6, 2025 •

Copy link
Copy Markdown
Contributor

Implements an AI-powered orchestration system for the complete geophysical processing pipeline: load ERT → invert → convert to water content → report, with optional seismic integration for structure-constrained inversion.

Architecture

AgentCoordinator orchestrates workflow execution with state management and error recovery.

Five specialized agents:

  • ERTLoaderAgent - Multi-format data loading (14+ instruments) with AI quality assessment
  • ERTInversionAgent - Resistivity inversion with GPT-4 parameter recommendations
  • WaterContentAgent - Petrophysical conversion with Monte Carlo uncertainty
  • SeismicAgent - Travel time inversion and interface extraction for structural constraints
  • ReportAgent - Markdown/HTML report generation with visualizations

Key Implementation Details

  • BaseAgent provides configurable LLM integration (gpt-4, gpt-3.5-turbo, etc.)
  • Graceful degradation without API key using sensible defaults
  • Robust LLM response parsing with regex fallbacks
  • Type-safe array operations with proper numpy checks
  • Optional dependency: openai>=1.0.0 in setup.py extras

Usage

from PyHydroGeophysX.agents import (
    AgentCoordinator, ERTLoaderAgent, ERTInversionAgent,
    WaterContentAgent, ReportAgent, SeismicAgent
)

coordinator = AgentCoordinator(api_key=os.getenv('OPENAI_API_KEY'))
coordinator.register_agent('ert_loader', ERTLoaderAgent())
coordinator.register_agent('ert_inversion', ERTInversionAgent())
coordinator.register_agent('water_content', WaterContentAgent())
coordinator.register_agent('seismic_processor', SeismicAgent())  # optional
coordinator.register_agent('report', ReportAgent())

results = coordinator.execute_workflow({
    'data_file': 'survey.dat',
    'instrument': 'E4D',
    'run_uncertainty': True,
    'n_realizations': 100,
    'use_seismic': True,  # enables structure-constrained inversion
    'velocity_threshold': 1200
})

Files Added

  • PyHydroGeophysX/agents/ - Complete agent system (~1,865 LOC)
  • examples/Ex_multi_agent_workflow.py - Working demonstrations
  • PyHydroGeophysX/agents/README.md - API documentation

Integration

  • Uses existing data_processing.ert_data_agent for loading
  • Delegates to inversion.ert_inversion for computation
  • Leverages Geophy_modular.ERT_to_WC for petrophysics
  • Integrates Geophy_modular.seismic_processor for constraints

System works with or without OpenAI API key - LLM features enhance but don't gate core functionality.

Original prompt

I want to use GPT API to create multiple agents to “load ERT → invert → convert to water content → report,” aligned with your PyHydroGeophysX structure. you can read all of my examples. also if seismic data existed, we can have addional agent to get it into process


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits November 6, 2025 21:21
Co-authored-by: geohang <75149424+geohang@users.noreply.github.com>
Co-authored-by: geohang <75149424+geohang@users.noreply.github.com>
Co-authored-by: geohang <75149424+geohang@users.noreply.github.com>
Co-authored-by: geohang <75149424+geohang@users.noreply.github.com>
Copilot AI changed the title [WIP] Add multiple agents for ERT processing and reporting Add GPT API-based multi-agent system for automated ERT workflows Nov 6, 2025
Copilot AI requested a review from geohang November 6, 2025 21:32
@geohang

geohang commented Nov 6, 2025

Copy link
Copy Markdown
Owner

This is for adding agent function to my code!

@geohang
geohang marked this pull request as ready for review November 6, 2025 21:35
@geohang
geohang merged commit 7f1af04 into main Nov 6, 2025
1 check passed
@geohang

geohang commented Nov 6, 2025

Copy link
Copy Markdown
Owner

@copilot not only ERT, in the future, it can get other geophysical data into hydrologic information. I want to use this agent to publish a paper like "Automatic cross‑modal geophysics agent for subsurface hydrology." so update the describiton. also not only GPT API. we can also add others like gemimi and claude

@geohang
geohang deleted the copilot/create-multiple-agents-for-processing branch November 7, 2025 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants