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

Implementation:ANative Lab EvoAgentX AFlowUtils

From Leeroopedia
Knowledge Sources
Domains Optimization, Utils
Last Updated 2026-10-21 00:00 GMT

Overview

Concrete utility classes for AFlow workflow optimization including data management, evaluation, experience tracking, and graph manipulation.

Description

The AFlow utilities support the `AFlowOptimizer` with dataset management, evaluation, experience-based learning, and graph manipulation:

  • DataUtils (`data_utils.py`) — Data loading/saving, sample selection, and `test_case_2_test_function` conversion. Downloads and manages benchmark datasets.
  • EvaluationUtils (`evaluation_utils.py`) — Wraps `AFlowEvaluator` for async graph evaluation against benchmarks. Handles validation rounds and score aggregation.
  • ExperienceUtils (`experience_utils.py`) — Loads/saves past optimization experiences (graph modifications and results) to guide future optimization. Supports Graph and Prompt modes. Samples from experience to guide new modifications.
  • GraphUtils (`graph_utils.py`) — Loads, saves, and modifies AFlow workflow graphs. Uses `WORKFLOW_OPTIMIZE_PROMPT` templates. Supports graph code generation, prompt extraction, and operator mapping.

Usage

  • Dataset management: `DataUtils` loads and manages benchmark data for optimization.
  • Graph evaluation: `EvaluationUtils` evaluates candidate graphs during optimization.
  • Experience learning: `ExperienceUtils` enables learning from past optimization rounds.
  • Graph manipulation: `GraphUtils` generates and applies graph modifications.

Code Reference

Source Location

Signature

class DataUtils:
    def load_data(self, path: str) -> Any
    def test_case_2_test_function(self, test_case: dict) -> Callable

class EvaluationUtils:
    async def evaluate_graph(self, graph, benchmark, ...) -> float

class ExperienceUtils:
    def load_experience(self, path: str) -> dict
    def sample_experience(self, ...) -> dict

class GraphUtils:
    def load_graph(self, path: str) -> str
    def save_graph(self, graph_code: str, path: str) -> None
    def modify_graph(self, graph_code: str, modification: str) -> str

Import

from evoagentx.utils.aflow_utils.data_utils import DataUtils
from evoagentx.utils.aflow_utils.evaluation_utils import EvaluationUtils
from evoagentx.utils.aflow_utils.experience_utils import ExperienceUtils
from evoagentx.utils.aflow_utils.graph_utils import GraphUtils

I/O Contract

Inputs

Name Type Required Description
path str Yes File/dataset path
graph str Yes (graph) │ Graph code
benchmark Benchmark Yes (eval) Benchmark for evaluation

Outputs

Name Type Description
evaluate returns float │ Average score
load_experience returns dict │ Past optimization experiences

Usage Examples

Evaluate a Graph

from evoagentx.utils.aflow_utils.evaluation_utils import EvaluationUtils

eval_utils = EvaluationUtils()
score = await eval_utils.evaluate_graph(graph, benchmark, validation_rounds=5)

Related Pages

Implements Principle

Requires Environment

Page Connections

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