MCPcopy Index your code
hub / github.com/FareedKhan-dev/long-running-agent

github.com/FareedKhan-dev/long-running-agent @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
586 symbols 2,789 edges 136 files 217 documented · 37%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

LRA — Long-Running Agents

A durable, self-improving agent organization that makes verified progress on software missions spanning days to weeks — surviving crashes, reboots, and context-window limits without losing the plot.

Durable execution (Temporal) · git as source of truth · deterministic verification · pluggable models · runs at $0


Status: early / work-in-progress (Phase 0). The durable core is being built first. See the roadmap and what's proven vs. frontier. This README describes the system as designed; features are landed incrementally and nothing here is marketing — see the honesty section.

What this is

Most "autonomous agents" are a single LLM loop that dies the moment the process restarts, the context window fills, or an API call fails. LRA treats long-horizon autonomy as an engineering problem, not a model capability. The model thinks in short bursts; the system runs for weeks by:

  • Externalizing the source of truth. The context window is a lossy cache. The real state — a git repo + a structured progress/checklist/decision log — lives outside it and is re-read every cycle ("assume interruption"). A reboot on day 12 reconstructs situational awareness in seconds.
  • Durable execution. The agent loop runs inside a Temporal workflow. Every LLM/tool call is a journaled, retried, replay-from-cache activity, so a crash resumes exactly where it left off — no work lost, no tokens re-spent. Idle time is spent in durable sleep at zero cost.
  • Deterministic verification. A checklist item is only "done" when real tests/lint/build/ typecheck pass — never on the model's say-so. This is what stops per-step errors compounding over thousands of steps.

The architecture (in one picture)

An asymmetric agent organization: one single-threaded Lead Engineer owns all coupled code-writes (so design decisions stay coherent), and specialized agents fan out only for the two things that genuinely parallelize — reading the codebase and independently reviewing the work. This is a deliberate, evidence-based choice (see docs/architecture.md).

        HUMAN ── approve · steer · gate irreversible acts (durable signals)
                                │
   ┌────────────────────────────▼─────────────────────────────┐
   │  MissionWorkflow  (Temporal orchestrator — thin scheduler) │
   └──┬──────────┬───────────┬───────────┬───────────┬─────────┘
      ▼          ▼           ▼           ▼           ▼
  [Planner]  [LEAD ENG]  [Researchers] [Reviewer]  [Integrator]
  DAG +      sole writer  (read-only    (fresh ctx, single
  ownership  (SDK loop)   fan-out)      adversarial) write to main
  ─────────── GROUND TRUTH: git + checklist ───────────
  ─────────── VERIFIER: pytest + ruff + mypy + build (the only merge gate) ───────────

Runs at $0 — and never faked

The only real cost is LLM tokens, and the model layer is pluggable behind one interface:

Backend Cost Notes
Ollama (local) $0 Real outputs, offline, fully yours. Needs a capable machine.
Free-tier cloud (OpenAI-compatible: Groq / Gemini / OpenRouter) $0* Stronger than small local models; rate-limited.
Claude (API key, or Agent SDK via a Pro/Max subscription) varies Strongest output; subscription = $0 marginal within plan limits.
stub $0 Deterministic test double — for tests/CI only, never shown as a real run.

Honesty is the whole point of this project. Every number you see (tokens, cost, latency) is read from the real provider response. Anything presented as a real agent run uses genuine model output or a clearly-labeled recorded replay — never fabricated text dressed up as live AI.

What's proven vs. frontier

  • Proven & tested: durability/crash-recovery, externalized state, deterministic verification gating, the coordination protocol, observability.
  • 🔬 Frontier (do not over-claim): fully hands-off multi-week autonomy. No model today does this reliably (METR task horizons are still well under a day at high reliability). LRA's claim is that the system runs for weeks (sleeps, survives, resumes) while the model drives it in verified bursts, with human gates on irreversible actions.

Quickstart

uv sync                 # install (provisions Python 3.12)
uv run lra version
uv run lra config       # show resolved config (secrets redacted)

More commands land with each phase. See docs/predicted-runs/ for clearly-labeled predicted outputs you can compare against your own real runs.

Roadmap

Built lean-baseline-first; the multi-agent org is layered on only where it provably helps.

  • Phase 0 — durable single-agent spine + crash-recovery test ← in progress
  • Phase 1 — deterministic verifier as a measured gate
  • Phase 2 — independent reviewer/critic + decision log
  • Phase 3 — read-only researcher fan-out
  • Phase 4+ — planner + integrator + conditional parallel writers; memory + skills; offline evolution

License

MIT — see LICENSE.

Core symbols most depended-on inside this repo

get
called by 72
src/lra/memory/skills.py
append
called by 39
src/lra/memory/episodic.py
failure
called by 16
src/lra/contracts/tools.py
default_local_tools
called by 16
src/lra/execution/tools/__init__.py
get_settings
called by 13
src/lra/config.py
complete
called by 12
src/lra/model/stub.py
run
called by 12
src/lra/contracts/tools.py
open
called by 12
src/lra/contracts/sandbox.py

Shape

Method 237
Function 201
Class 148

Languages

Python100%

Modules by API surface

src/lra/execution/sandbox_docker.py16 symbols
src/lra/state/mission_anchor.py15 symbols
src/lra/contracts/state.py14 symbols
src/lra/execution/tools/fs.py12 symbols
src/lra/execution/sandbox_local.py12 symbols
src/lra/contracts/sandbox.py11 symbols
src/lra/cli/main.py11 symbols
tests/unit/test_more_modules.py10 symbols
src/lra/memory/hybrid.py10 symbols
src/lra/execution/sandbox_e2b.py10 symbols
src/lra/contracts/tools.py10 symbols
tests/durability/test_hardening.py9 symbols

Datastores touched

langfuseDatabase · 1 repos

For agents

$ claude mcp add long-running-agent \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact