FeynFacet

Example: a new process with an AI agent

FeynFacet is meant to be extended. This example uses a coding agent (for instance Codex or Claude Code) to compute a process that is not in the repository, prompt-photon production in proton–proton collisions, $p+p\to\gamma+X$, and to check the result against a published calculation.

Before you start

An AI coding agent installs and checks the tools for you; you do not need to set them up one by one.

  1. Install Mathematica and clone the repository.
  2. Start the agent in the repository folder, with permission to run Mathematica and the external tools without approving each command: Codex with codex --approve-for-me (or “Approve for me” under /permissions at the start of a session); Claude Code in auto mode (Shift+Tab, or claude --permission-mode auto). The tools write to their user and temporary directories, which a restrictive sandbox blocks.
  3. Paste the setup prompt below. The agent installs FeynCalc, FeynArts, FORM, Tracer, Kira, Fermat and SubTropica and runs the toolchain check until it reports READY.
Set up FeynFacet on this machine. Install the tools it needs, following
docs/INSTALL.md (docs/INSTALL-macOS.md on a Mac; on Apple silicon, build
Kira with tools/install_kira.py as described there), and run
python3 feynfacet.py check --all-routes until it reports READY.
Ask me before anything that needs an administrator password.

The installation notes are what the agent follows. Mathematica and its license stay with you, and the agent asks before anything that needs your administrator password; on a Mac this includes Homebrew and Apple's Command Line Tools for Xcode. On Apple silicon the agent builds a patched Kira, since the Kira 3.1 release build can silently return wrong reductions there (details); this one-time build takes a few minutes.

If the tools are not yet installed, you can also go straight to the prompt below: its first step installs whatever is missing.

The prompt

We tested this example with Codex using GPT-6-Astra at maximum reasoning effort, and with Claude Code using Claude Opus 5.5.

Steps 1, 3 and 5 form a template that applies to any new calculation; steps 2 and 4 describe this process and the renormalization and factorization it needs. To compute another process, change those two steps.

1. Learn FeynFacet

The FeynFacet repository is supplied in this working directory.
Read and follow its AGENTS.md, README.md and relevant
documentation, and study the existing processes: their conventions,
shared routines, execution procedure and validation checks.
Run python3 feynfacet.py check --all-routes. If a tool is missing or the
check does not report READY, install or fix it following docs/INSTALL.md
(docs/INSTALL-macOS.md on a Mac), and ask me before anything that needs
an administrator password.
Identify the existing process implementations closest to the task
below and use them as templates, explaining your choice.

2. Specify the process and observable

Derive and execute the analytical LO and NLO QCD calculation for
inclusive prompt-photon production, p + p -> photon + X, for both
unpolarized and double-longitudinally polarized beams.

For this example, compute the q + qbar -> photon + X direct partonic
channel, without photon isolation. Treat X inclusively and include
every contributing NLO final state for this incoming channel.

Derive the result independently: do not search online for, or use,
published results for this process.

3. Choose and apply a workflow

Use one supported FeynFacet algebra workflow: FeynCalc, FORM or Tracer.
Identify the chosen route. Follow FeynFacet's cross-section normalization,
kinematic variables, dimensional and spin conventions.

Derive the coefficients from amplitudes using reverse unitarity,
dimensional shifts where applicable, Kira reduction and SubTropica
integration, following the existing workflow.

4. Renormalization and factorization

Determine and implement the renormalization and factorization terms
required to obtain finite hard coefficients, following FeynFacet's
conventions. Identify and derive any process-specific ingredients
missing from the existing examples.

For this non-isolated photon process, include photon-fragmentation
factorization in the MSbar scheme. Explain the subtraction conventions
and retain the dependence on the relevant scales.

5. Execute, validate and provide results

Work in a new directory, preserving the supplied sources and results.
Develop and execute the calculation. Apply all internal consistency
and validation checks applicable to this calculation and the chosen
workflow, following FeynFacet's existing implementations.

Provide readable, executable sources and notebooks, complete finite
analytic coefficients including their distribution and scale dependence,
the conventions used, and a summary of the checks and their results.

Optional: compare with the literature

The annihilation channel was computed at NLO by Gordon and Vogelsang, Polarized and unpolarized prompt photon production beyond the leading order, Phys. Rev. D 48 (1993) 3136, who give the complete coefficients in their appendices. After the calculation, a second prompt asks the agent to compare:

Compare these results with Gordon–Vogelsang, Phys. Rev. D 48 (1993) 3136:
unpolarized LO Eq. (12) and polarized LO Eq. (14); NLO Eq. (36) with
Appendices D/E. Translate normalization and factorization conventions as
necessary; for the polarized initial state, Gordon–Vogelsang use the MS_P
scheme of their Eqs. (32)–(33), so report the scheme-transformation term
separately. Report exact symbolic differences. If you cannot open the paper,
stop and ask me for the PDF instead of working from memory.

The agent needs to read the paper itself. If it cannot open the article online, for example without a journal subscription, download the PDF yourself and save it where the agent can read it, such as the repository folder. Then add its location to the prompt, for example: “The paper is at ~/Downloads/GordonVogelsang1993.pdf.”

The unpolarized coefficients should agree exactly. For the polarized initial state, Gordon and Vogelsang use the MSP scheme of their Eqs. (32)–(33), while FeynFacet uses HVBM with the finite term $\Delta f_{qq}(z)=-4C_F(1-z)$ that restores the helicity convention of the polarized MSbar parton distributions (conventions); the two differ by a finite factorization term, which the comparison should identify explicitly.

What to expect

The computation itself takes minutes; an agent session that builds and validates the new workflow takes longer. Agent output varies from run to run: read the notebooks as you would any calculation, and rely on the checks and the comparison rather than on the agent's summary.