Skip to main content
The nightly loop is TENET’s autonomous improvement engine. It runs while you sleep, making focused code changes, measuring results, and keeping only what improves.

How It Works

Every night at 2 AM (configurable):
  1. Mine tuples — Extract training data from today’s journal entries
  2. Synthesize context — Generate product context summary for agents
  3. Strategic reasoning — Stratus decides which agents to run based on ROI
  4. Run agents — 5 rounds per agent, ~1 hour total
  5. Retrain policy head — If 50+ new tuples since last training
  6. Pick up backlog — Grab GitHub/Linear issues for autonomous PRs

Setup

If you have OpenClaw running, add a cron job:
{
  "name": "nightly-loop",
  "schedule": { "kind": "cron", "expr": "0 2 * * *", "tz": "America/Denver" },
  "payload": {
    "kind": "agentTurn",
    "message": "cd ~/CascadeProjects/my-project && jfl peter daily >> .jfl/nightly.log 2>&1",
    "timeoutSeconds": 3600
  }
}

System Cron

# crontab -e
0 2 * * * cd /path/to/project && jfl peter daily >> .jfl/nightly.log 2>&1

Manual Run

jfl peter daily

What to Expect

First run output:
  Peter Parker - Daily RL Agent Loop

  Found 5 RL agent(s):
    • test-coverage (coverage_percent, maximize)
    • code-quality (quality_score, maximize)
    • cli-speed (p90_ms, minimize)
    • telemetry-rl (product_health, maximize)
    • onboarding-success (success_rate, maximize)

  Pre-flight: Mining tuples from journals...
    Mined 12 tuples, 8 new → buffer total: 2772

  Pre-flight: Synthesizing product context...
    ✓ Product context updated

  Layer 3: Strategic reasoning...
    Run: ["test-coverage", "code-quality"]
    Skip: ["cli-speed"] — near optimal
    Reasoning: test-coverage has highest gradient (87% headroom)

  Hub health: ✓ (12ms)

  ── test-coverage ──────────────────────────────
    Baseline: 0.1276
    Round 1: +0.0031 KEPT
    Round 2: -0.0002 REVERTED
    Round 3: +0.0018 KEPT
    Round 4: +0.0012 KEPT
    Round 5: -0.0001 REVERTED

  ── code-quality ───────────────────────────────
    Baseline: 0.6836
    Round 1: +0.0045 KEPT
    ...

  Daily loop complete.

Monitoring

Check Last Night’s Results

# View the log
tail -100 .jfl/nightly.log

# Run the scorecard
bash eval/nightly-scorecard.sh

Scorecard Output

╔════════════════════════════════════════════╗
║           JFL Nightly Scorecard            ║
╚════════════════════════════════════════════╝

┌──────────────────┬──────┬──────┬──────────┐
│ Agent            │ Runs │ Kept │ Signal?  │
├──────────────────┼──────┼──────┼──────────┤
│ test-coverage    │   15 │    8 │    ✓     │
│ code-quality     │   10 │    4 │    ✓     │
│ cli-speed        │  174 │   16 │    ✓     │
└──────────────────┴──────┴──────┴──────────┘

  Keep rate: 28/199 (14.1%)

Tuning

Rounds Per Agent

Default is 5. Increase for agents with high gradient:
# .jfl/agents/test-coverage.toml
rounds = 20  # More rounds = more improvement per night

Strategic Reasoning

PP uses recent agent performance to decide who runs. If an agent has plateaued (0 improvements in last 10 runs), it gets skipped automatically.

Cost Control

Each round costs ~0.501.00inAPItokens(dependsonmodel).5agents×5rounds= 0.50-1.00 in API tokens (depends on model). 5 agents × 5 rounds = ~15/night. Use --budget to cap costs:
jfl peter daily --budget 10  # Stop at $10