High-Level Architecture
AIDE ML is designed as a modular system with several key components that work together to execute the agentic tree search. Understanding this architecture is helpful for extending the system or interpreting its behavior.
Core Components
-
Runner (
aide/run.py
)- This is the main entry point for the CLI (
aide
command). - It handles loading the configuration, preparing the agent's workspace, and orchestrating the main loop.
- It uses the
rich
library to provide a real-time terminal user interface that displays the task description, progress, and a live view of the solution tree.
- This is the main entry point for the CLI (
-
Agent (
aide/agent.py
)- This is the "brain" of the system. The
Agent
class holds the core logic for the agentic tree search. - It compiles and sends prompts to the LLM backend to generate code.
- It contains the logic for the three primary actions: drafting a new solution, improving an existing one, and debugging a buggy one.
- It implements the
search_policy
to decide which node in the tree to work on next. - It also uses an LLM to parse and analyze the results of code execution to extract metrics and generate feedback.
- This is the "brain" of the system. The
-
Interpreter (
aide/interpreter.py
)- This component provides a secure, sandboxed environment for executing the Python code generated by the agent.
- It runs the code in a separate process using Python's
multiprocessing
library to isolate it from the main agent process. - It captures all standard output (
stdout
), standard error (stderr
), and exceptions, returning them in a structuredExecutionResult
object. - It enforces a configurable
timeout
to prevent code from running indefinitely.
-
Journal (
aide/journal.py
)- This is the central data structure of the system, acting as the agent's memory.
- The
Journal
class holds a list of allNode
objects generated during a run. - Each
Node
represents a single attempt (a script and its result) and is linked to its parent, forming the solution tree. - The Journal provides helper methods to query the state of the search, such as
get_best_node()
,buggy_nodes
, andgood_nodes
.
-
LLM Backend (
aide/backend/
)- This is a modular interface for communicating with various LLM providers.
- The
__init__.py
file contains a provider-agnosticquery
function that automatically routes requests to the correct backend based on the model name (e.g.,gpt-
,claude-
). - It currently supports OpenAI, Anthropic, Gemini, and OpenRouter, making the agent model-neutral.
- It handles prompt compilation, API-specific formatting (like function calling/tool use), and backoff/retry logic for API requests.
Workflow
A typical run proceeds as follows:
- The Runner initializes the Agent, Interpreter, and an empty Journal.
- The Runner enters a loop for the configured number of steps.
- In each step, the Agent's
search_policy
selects a parent node (orNone
to draft). - The Agent generates a new plan and code, creating a new
Node
. - The new
Node
's code is passed to the Interpreter for execution. - The
ExecutionResult
is returned to the Agent. - The Agent uses the LLM Backend to analyze the result, extracting a metric and generating analysis.
- The fully populated
Node
is appended to the Journal. - The Runner saves the updated journal and visualization, and the loop continues.