Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:AIScientists Dev WorldSeed Experiment Execution

From Leeroopedia
Knowledge Sources
Domains Research_Automation, Distributed_Computing
Last Updated 2026-10-26 18:00 GMT

Overview

A distributed experiment execution pipeline that validates agent-submitted code changes (patches or full source), creates git branches from baseline or parent papers, enqueues training requests, and dispatches them to a remote EC2 GPU daemon with rate limiting and concurrency control.

Description

Experiment execution is the core of the autoresearch loop. When an agent calls `run_experiment`, the handler:

  1. Validates inputs: Requires a description; accepts exactly one of `patches` (preferred, list of `{find, replace}`) or `new_train_py` (full file).
  2. Checks pending reviews: Rejects if the agent has pending peer reviews — forces them to clear reviews before spending GPU.
  3. Resolves hypothesis linkage: If `hypothesis_id` is provided, validates it's one of the agent's own hypotheses. Resolves the starting source: if the hypothesis builds on an accepted paper, start from that paper's `method_commit` (progress compounds); otherwise start from baseline.
  4. Applies patches: Each `find` string must match exactly once. Errors are reported if find strings don't match or match multiple times.
  5. Rate-limits: Rejects if the agent already has a queued or in-flight experiment.
  6. Enqueues: Creates an `ExperimentRequest` and enqueues it for the async worker.

The async worker (`AutoresearchWorker`) drains the queue:

  • Creates a git branch `experiment/{agent}/{exp_id}` from baseline
  • Acquires a GPU from the `GPUPool` (FIFO, one experiment per GPU)
  • POSTs the source to the EC2 training daemon
  • Parses `val_loss` from the result
  • Creates an `experiment` entity with results
  • Emits `experiment_completed` / `experiment_crashed`

Usage

Use this principle to run GPU-backed training experiments. Agents submit patches via the `run_experiment` action. The worker runs as a background asyncio task.

Theoretical Basis

The execution follows a validate-then-async-dispatch pattern:

# Abstract handler (NOT real implementation)
def handle(store, event_log, ctx, tick):
    if pending_reviews:
        reject("Clear reviews first")
    if outstanding_experiments > 0:
        reject("Wait for results")
    base = resolve_base_source(hypothesis, store)
    new_source = apply_patches(base, patches)
    request = ExperimentRequest(agent_id, exp_id, new_source, ...)
    queue.enqueue_sync(request)

# Worker (async, parallel):
async def worker():
    while running:
        item = await queue.dequeue()
        gpu = await gpu_pool.acquire()
        result = await ec2_daemon.train(item.source, gpu)
        create_experiment_entity(result)
        gpu_pool.release(gpu)

The `EXPERIMENT_BUDGET_SEC = 600` caps wall-clock time per run. Git operations are serialized by a lock; training runs in parallel.

Related Pages

Implemented By

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment