Long-running Claude for scientific computing

Anthropic has demonstrated that multi-day agentic coding workflows can automate complex scientific computing tasks, compressing months of human researcher effort into a few days. By utilizing Claude Opus 4.6 with persistent memory, test oracles, and specific orchestration patterns, a non-domain expert was able to implement a differentiable cosmological Boltzmann solver from scratch with sub-percent accuracy compared to reference implementations.

Autonomous Agentic Workflows for Science

Scientific computing tasks—such as reimplementing numerical solvers, converting legacy Fortran code to modern languages, or debugging large codebases—are well-suited for autonomous agents because they typically have well-scoped objectives and clear success criteria. Unlike parallelizable tasks, scientific pipelines are often deeply coupled, where a small numerical error in one stage can propagate downstream. This requires a sequential agent approach that can trace causal chains, draw from domain knowledge, and use reference implementations to bisect discrepancies.

Technical Framework for Long-Running Agents

To enable autonomous work over several days, Anthropic identifies several key architectural components:

Project Instructions (CLAUDE.md)

Instructions are codified in a CLAUDE.md file in the root directory. Claude treats this file as a persistent context, referencing it for the overall plan and updating it as the project evolves. In the cosmological solver example, the goals were defined as achieving full feature-parity with the reference CLASS implementation and an accuracy target of 0.1%.

Persistent Memory (CHANGELOG.md)

To prevent the agent from repeating failed attempts, a CHANGELOG.md file serves as portable long-term memory. This file tracks:

  • Current status and completed tasks.
  • Failed approaches and the reasons for failure (e.g., switching from Tsit5 to Kvaerno5 for a stiff perturbation ODE).
  • Accuracy tables at key checkpoints.
  • Known limitations.

The Test Oracle

Autonomous progress depends on a "test oracle"—a way for the agent to verify its work. For scientific code, this is typically a reference implementation, a quantifiable objective, or an existing test suite. In this project, Claude used the CLASS C source as a reference to construct and continuously run unit tests.

Coordination via Git

Git is used to monitor progress and ensure recoverability. The agent is instructed to commit and push after every meaningful unit of work, provided that pytest passes, ensuring that no breaking changes are committed.

Execution and Orchestration

HPC Integration

For compute-heavy tasks, Claude Code can be run within a terminal multiplexer like tmux on an HPC cluster using the SLURM job scheduler. This allows the agent to run in the background while the human user occasionally detaches and re-attaches to steer the process or check progress via GitHub.

The Ralph Loop

To combat "agentic laziness"—where a model may stop before a complex task is fully complete—Anthropic utilizes the "Ralph loop." This is a for loop orchestration pattern that re-prompts the agent when it claims completion, asking if it is truly finished.

In the provided example, the Ralph loop was invoked via a plugin with a specific success criterion:

/ralph-loop:ralph-loop “Please keep working on the task until the success criterion of 0.1% accuracy across the entire parameter range is achieved.” --max-iterations 20 --completion-promise “DONE”

Results and Implications

Using this framework, Claude Opus 4.6 implemented the clax project from scratch over several days, eventually reaching sub-percent agreement with the reference CLASS implementation. While the agent's trajectory was "clunky"—including gaps in test coverage and occasional elementary mistakes regarding gauge conventions—it maintained sustained progress toward the target.

This demonstration suggests that agent-driven development can significantly compress the timeline for scientific software development. The author notes that the opportunity cost of not running agents on well-defined projects is now a tangible loss of potential progress.

Sources

Related

  • Dispatch
  • Dispatch
  • Dispatch
  • Dispatch
  • Dispatch