The Big Picture
When you callkapso.evolve(), the OrchestratorAgent runs an experiment loop that generates, tests, and refines solutions until the feedback generator decides the goal is achieved.
Step by Step
Step 1: Initialize Components
Whenevolve() is called, Kapso creates the execution stack:
Step 2: Gather Context
The ContextManager assembles information for the coding agent:Step 3: The Solve Loop
OrchestratorAgent.solve() runs the main loop:Step 4: Generate Solution Ideas
SearchStrategy generates solution candidates: GenericSearch — Claude Code + MCP gates:Step 5: Write Code and Run Evaluation
ExperimentSession coordinates code generation:- Implementing the solution code
- Building evaluation in
kapso_evaluation/ - Running the evaluation
- Returning structured JSON with results
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.
Each experiment gets its own Git branch via ExperimentWorkspace:
Step 6: Agent Returns Structured JSON
The developer agent returns a structured JSON with evaluation results:Step 7: Feedback Generation
The FeedbackGenerator validates the evaluation and decides whether to continue:- Validates evaluation: Checks if the agent-built evaluation is fair and correct
- Extracts score: Parses the evaluation output to get numeric scores
- Checks goal: Determines if the goal has been achieved
- Generates feedback: Provides actionable suggestions for the next iteration
Step 8: Check Feedback Result
The search strategy checks the feedback result:Step 9: Optional External Evaluation
Wheniteration_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:Budget Tracking
OrchestratorAgent tracks three budgets:
The loop stops when any budget hits 100% OR the stop condition is met.
Error Handling
Errors are captured in SearchNode:Next Steps
Search Strategies
Linear vs Tree search in detail
Orchestrator
Deep dive into OrchestratorAgent
Feedback Generator
How evaluation is validated
Coding Agents
Pluggable code generators