Skip to main content
One call to evolve() runs a loop: gather context, propose a candidate, implement it on a branch, evaluate it, judge the result, and either continue or stop. This page follows a single pass through it.

Step by step

Step 1: Initialize components

When evolve() is called, Kapso creates the execution stack:

Step 2: Gather context

The problem handler supplies the problem statement; knowledge search adds graph context. Experiment history and repo memory are not packed into the context — the agent pulls them on demand through MCP gates.

Step 3: The solve loop

OrchestratorAgent.solve() runs the main loop: compute budget progress, hand the strategy the problem plus the previous iteration’s feedback, run one search iteration, and stop on a judged goal-achieved vote or an exhausted budget. The faithful sketch lives on the orchestrator page.

Step 4: Generate solution ideas

SearchStrategy generates solution candidates: The generic strategy picks a parent (see parent selection), runs ideation against the MCP gates, and carries the chosen solution into implementation:

Step 5: Write code and run evaluation

ExperimentSession coordinates code generation:
The coding agent is responsible for:
  1. Implementing the solution code
  2. Building evaluation in kapso_evaluation/
  3. Running the evaluation
  4. Ending its response with the XML result tags
When the caller supplies eval_dir, step 2 changes: the agent must run the provided evaluation without changing its source. Kapso fingerprints the suite and verifies the finalized candidate ref before accepting its score. See Evaluation Integrity. A session can also stop instead of finishing. When the session needs something only a person can provide, the session calls the request_from_user tool; the session ends, the node is suspended, the campaign pauses with stopped_reason: waiting_for_user, and the judge never sees the node. Your reply through the inbox continues the same session at this step, with the reply as its next input. Each experiment gets its own Git branch via ExperimentWorkspace:

Step 6: Agent returns XML result tags

The coding agent ends its response with XML tags:
The tags are extracted from the agent’s output and handed to the feedback generator.

Step 7: Feedback generation

The feedback generator reads the diff and the session’s tags, validates the evaluation, extracts the score, checks the goal, and writes the next iteration’s feedback — returning a FeedbackResult with stop, evaluation_valid, feedback and score.

Step 8: Check feedback result

The search strategy checks the feedback result:

Step 9: Optional external evaluation

When iteration_evaluator is configured, Kapso evaluates every candidate finalized by the strategy before writing experiment history or a run checkpoint. Each candidate ref is materialized in a temporary detached worktree. Returned metrics are stored on node.metrics and remain observational: node.score still controls search and best-branch selection. See External Iteration Evaluation for the callback contract, isolation model, and failure policies.

Step 10: Return result

When the loop ends, Kapso returns the best solution:

How is the budget tracked?

Budget progress is the maximum of the time, iteration and cost dials; the loop stops when any of them reaches 100% or the judge’s stop vote is honored. The formula and dials are on the orchestrator page.

What happens when a step fails?

Errors are captured in SearchNode:
There is no in-iteration debug loop: an error lands in the node’s tags and the judge’s verdict, and the next iteration’s prompt opens with that feedback.

Search Strategies

The generic strategy in detail

Orchestrator

Deep dive into OrchestratorAgent

Feedback Generator

How evaluation is validated

Coding Agents

Pluggable code generators
Related pages: Search Strategies · Orchestrator · Feedback Generator · Coding Agents Kapso is an open-source framework by Leeroo that builds software toward measurable goals through experiment campaigns. Source code: github.com/Leeroo-AI/kapso · Install: pip install leeroo-kapso · Every page as plain text: llms.txt.