Skip to main content

Project

coverage

Introduction

hepagent is an AI agent framework tailored for High Energy Physics (HEP) and cosmology workflows. Key features include:

  • Multi-provider LLM support: seamlessly switch between providers such as cborg, openai, amsc, and gemini via a unified CLI (hepagent run, hepagent repl) or programmatic API, with per-provider configuration managed in providers.toml.
  • Skill-based domain knowledge: a modular skill registry (.agents/skills/) packages domain-specific instructions (e.g. running Nyx cosmology simulations, accessing CERN Open Data) that agents load on demand, keeping prompts concise and context-relevant.
  • CLI REPL: a Claude Code-inspired interactive REPL (hepagent repl) with slash commands, streaming transcript output, command approval prompts, and markdown/code rendering.
  • Bash and execution modes: interactive shell-capable agents with configurable YOLO (auto-approve), CONFIRM, and HUMAN execution modes, output character limits, and turn budgets—safe for running on HPC clusters.
  • Textual TUI agent: a rich Terminal User Interface (TextualAgent) with real-time display of agent thinking, step navigation, and live cost tracking.
  • HPC / Slurm integration: built-in tooling for submitting and monitoring Slurm jobs, Globus data transfers, and IRI compute resources.
  • Extensible tool system: common and domain-specific tools are registered under src/hepagent/tools/, making it straightforward to add new capabilities without touching agent logic.
  • Autonomous analysis pipeline (in development): a 5-phase multi-agent orchestration system (hepagent jfc) that drives a HEP physics analysis from a natural-language prompt to an analysis note. Each phase (Strategy → Exploration → Processing → Inference → Documentation) is executed by a dedicated executor agent, then evaluated by a panel of parallel reviewer agents (physics reviewer, critical reviewer, constructive reviewer) whose findings are adjudicated by an arbiter before the pipeline advances. Optional physicist co-design gates allow human-in-the-loop review at phase boundaries. Artifacts (STRATEGY.md, EXPLORATION.md, analysis note PDF, etc.) are written to a structured directory and reproduced via pixi run all.

Installation

Quick start (no code checkout required)

With uv installed, you can run hepagent directly from PyPI without cloning the repository:

# Run once without installing permanently
uvx hepagent -h

# Or install as a persistent tool
uv tool install hepagent
hepagent -h

Developer setup (from source)

git clone https://github.com/xju2/hepagent.git
cd hepagent
uv python install 3.12
make sync
source .venv/bin/activate
export OPENAI_AGENTS_DISABLE_TRACING=1  # Optional: disable tracing logs if you don't have OPENAI_API_KEY
hepagent list-platforms
hepagent list-models --platform cborg

Configurations

After the installation, you can find default configurations at $HOME/.hepagent. The environment variables are stored in $HOME/.hepagent/config/env_vars.toml.

To use a LLM provider, set the corresponding API keys as environment variables. You may also want to set OPENAI_AGENTS_DISABLE_TRACING=1 to disable the tracing logs, especially if you do not have an OPENAI_API_KEY.

If you don't want to store API keys in the TOML file, you can set them to environment variables directly.

export CBORG_API_KEY="your-api-key"
export OPENAI_API_KEY="your-api-key"
export AMSC_API_KEY="your-api-key"
export GEMINI_API_KEY="your-api-key"

Instructions

Choose a platform and model

You can run the agent as in the following examples. The default model is cborg:lbl/gemma-4 if not specified.

List available models for a platform:

hepagent list-models --platform cborg
hepagent list-models --platform amsc
hepagent list-models --platform openai
hepagent list-models --platform gemini

Run an agent with a specific model and task:

hepagent run --agent "shell" --model "gemini:models/gemini-flash-lite-latest" "how many python files in this code repository"
hepagent run --agent "scientist" --model "cborg:lbl/gemma-4" "I would like to simulate a cosmology sky with Nyx code." --max-turn 30
hepagent run --agent "explorer" --model "openai:gpt-5-mini" "Suggest research directions connecting weak lensing and neutrino mass"
hepagent run --agent "coder" --model "openai:gpt-5-mini" "Create a worktree for adding a new feature: chunkle."
hepagent run --agent "scientist" --model "gemini:models/gemini-2.0-flash" "..."  # uses Gemini provider

YOLO mode (auto-approve all bash commands):

hepagent run --agent "scientist" --yolo "your task here"

Interactive REPL

Start the new CLI REPL:

hepagent repl

Examples:

hepagent repl --agent scientist
hepagent repl --agent explorer
hepagent repl --agent shell --model openai:gpt-5-mini
hepagent repl --chat my-session
hepagent repl --disable-session
hepagent repl --yolo
hepagent repl --max-turn 30

Supported slash commands:

  • /help
  • /quit
  • /clear
  • /agents
  • /agent <name>
  • /platforms
  • /platform <name>
  • /models [platform]
  • /model <name>
  • /mode <confirm|yolo|human>
  • /max-turn <turns>

For more detail, see docs/REPL.md.

Autonomous HEP analysis pipeline (hepagent jfc)

hepagent jfc drives a full HEP physics analysis from a natural-language prompt to a compiled analysis-note PDF. The pipeline runs seven phases sequentially; each phase is executed by a dedicated executor agent and then evaluated by a panel of parallel reviewer agents whose findings are adjudicated by an arbiter before the pipeline advances.

Phase Name Description
1 Strategy Define the analysis strategy and commit to key decisions
2 Exploration Explore datasets, signal/background properties
3 Processing Run selection, reconstruction, and histogram production
4a Expected Results Inference on expected (Asimov) data
4b 10% Validation Inference on 10% of observed data (human gate)
4c Full Data Inference on the full observed dataset
5 Documentation Write and typeset the final analysis note PDF

Start a new analysis

Create a markdown file with your physics question, then run:

hepagent jfc run \
  --name my_analysis \
  --type measurement \
  --prompt-file prompt.md

Options:

--name / -n          Analysis name (short identifier, used as directory name)
--type / -t          Analysis type: measurement or search
--prompt-file / -p   Path to a markdown file with the physics question
--model              Model as "provider:model" (e.g. "cborg:claude-sonnet-4-5")
--base-dir           Parent directory for analyses (default: analyses/)
--max-iterations     Max review iterations per phase before halting (default: 3)
--max-turns          Max agent turns per call (defaults: executor=50, note_writer/fixer=30, reviewers=20)
--yolo               Auto-approve all bash commands
--codesign           Enable human co-design review after Phase 1: generates a strategy summary,
                     facilitates interactive Q&A, then re-adjudicates before Phase 2

Example with a specific model and co-design enabled:

hepagent jfc run \
  --name atlas_zprime \
  --type search \
  --prompt-file tasks/zprime_search.md \
  --model cborg:claude-sonnet-4-5 \
  --codesign

Resume an interrupted analysis

State is saved automatically after every phase. Resume from any phase:

hepagent jfc resume --name my_analysis --from-phase 3
hepagent jfc resume --name my_analysis --from-phase 4a

Check analysis status

hepagent jfc status --name my_analysis

Output lists each phase with its status (✓ PASS, → IN PROGRESS, or ○ pending) and the number of review iterations used.

List all analyses

hepagent jfc list
hepagent jfc list --base-dir /path/to/analyses

References

This repository takes inspiration from and builds upon the following works:

Other related works:

Metadata

Release files for hepagent 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hepagent 0.4.0
File Size Uploaded
hepagent-0.4.0.tar.gz 727.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hepagent 0.4.0
File Interpreter ABI Platform
hepagent-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.0 MB

Release files / hepagent-0.4.0.tar.gz

Download URL hepagent-0.4.0.tar.gz
Size 727.7 kB
Tags Source
SHA-256 checksum
How to use checksums
42c63cad6946c6c754f8a77787c954f7d4f59de5bee1ef68b8f6c57fb4ff9b6c
BLAKE2b-256 checksum
How to use checksums
ce111d2f7bc1a89fbc0d7e474f54b58cc150de4c3f380e646bda5f44514b9485
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 16, 2026.

Transparency log

Release files / hepagent-0.4.0-py3-none-any.whl

Download URL hepagent-0.4.0-py3-none-any.whl
Size 320.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c59f9c335cb68b7b02dd02833aaab9db638d6a4d89bb8beb8138ec8966938075
BLAKE2b-256 checksum
How to use checksums
071ccfb1117cde82599e215fc6ed0fc95c3eb5bd5ecfbce1ceb32108a99a73e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.4

2 release files

0.3.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page