Extension Reference
This reference covers optional integration adapters that sit around fast-agent
rather than the core FastAgent class. Install the dependency extra for the
integration you need.
GEPA
GEPA support lives in fast_agent.integrations.gepa.
The published gepa extra installs PyPI GEPA and Trackio:
PyPI packages cannot declare direct Git dependencies in extras. Trackio-specific GEPA helpers require a GEPA release with Trackio support; until that support is available on PyPI, install the integration branch in your application environment:
Use the GEPA Optimization guide for workflow guidance. In short:
- use
FastAgentBatchEvaluatorwithoptimize_anything()for aggregate candidate scoring over a full JSONL batch; - use
FastAgentRowWiseBatchAdapterwithgepa.api.optimize()when GEPA should treat each input row as an optimization instance; - use
FastAgentReflectionLMwhen GEPA reflection calls should use fast-agent model aliases, configuration, and audit artifacts.
GEPA integration adapters
Import GEPA helpers from fast_agent.integrations.gepa. These adapters keep
fast-agent responsible for batch execution, artifact paths, and reflection LM
calls while leaving scoring policy in your evaluator code.
FastAgentReflectionLM
Synchronous language-model callable for GEPA reflection calls backed by
fast-agent go. It writes prompt, request, response, timing, stdout/stderr,
error, and usage artifacts under audit_dir.
FastAgentReflectionLM(
*,
env_dir: str | Path | None = None,
model: str | None = None,
audit_dir: str | Path,
agent: str | None = None,
timeout_seconds: float | None = None,
command_runner: CommandRunner | None = None
)
FastAgentBatchEvaluator
Aggregate GEPA evaluator for gepa.optimize_anything.optimize_anything: one
candidate runs one full fast-agent batch and returns one (score, side_info)
pair. Use this when the primary metric is corpus-level.
FastAgentBatchEvaluator(
*,
env_dir: str | Path | None = None,
agent_card: str | Path,
agent: str | None = None,
candidate_variables: Mapping[str, str],
input: str | Path,
template: str | None = None,
template_source: str | Path | None = None,
schema: str | Path | None = None,
model: str | None = None,
parallel: int | None = None,
scorer: BatchScorer,
run_dir: str | Path,
backend: BatchBackend = 'harness',
include_input: bool = True
)
FastAgentRowWiseBatchAdapter
Lower-level GEPA adapter protocol implementation for gepa.api.optimize: GEPA
supplies minibatches of input rows, fast-agent runs each minibatch through
BatchRunner, and your row_scorer returns one score/trajectory per row.
FastAgentRowWiseBatchAdapter(
*,
env_dir: str | Path | None = None,
agent_card: str | Path,
agent: str | None = None,
candidate_variables: Mapping[str, str],
template: str | None = None,
template_source: str | Path | None = None,
schema: str | Path | None = None,
model: str | None = None,
parallel: int | None = None,
row_scorer: RowWiseBatchScorer,
run_dir: str | Path,
backend: BatchBackend = 'harness',
include_input: bool = True,
id_field: str | None = None,
reflective_dataset_builder: ReflectiveDatasetBuilder | None = None,
batch_runner_factory: BatchRunnerFactory | None = None
)
adapter.evaluate(
batch: list[JsonRow],
candidate: dict[str, str],
capture_traces: bool = False
) -> Any
adapter.make_reflective_dataset(
candidate: dict[str, str],
eval_batch: Any,
components_to_update: list[str]
) -> Mapping[str, Sequence[Mapping[str, Any]]]
RowWiseScore
row_scorer may return RowWiseScore, a bare float, (score, trajectory),
or (score, trajectory, objective_scores). objective_scores values should
be higher-is-better because GEPA uses them for frontier tracking.
RowWiseScore(
score: float,
trajectory: Any = None,
objective_scores: Mapping[str, float] | None = None
) -> None
RowWiseEvaluationRun
Metadata passed to each row_scorer call for the current minibatch evaluation.
Trackio helpers
Trackio helpers provide fast-agent defaults for GEPA dashboards. Use
gepa_trackio_init_kwargs() when your script initializes Trackio, use
gepa_api_trackio_kwargs() with gepa.api.optimize(), and use
make_gepa_tracking_config() with optimize_anything().
gepa_trackio_init_kwargs(
*,
project: str = 'fast-agent-gepa',
name: str | None = None,
group: str | None = None,
config: Mapping[str, Any] | None = None,
embed: bool = False,
auto_log_gpu: bool = False,
**overrides: Any
) -> dict[str, Any]
gepa_api_trackio_kwargs(
*,
project: str = 'fast-agent-gepa',
name: str | None = None,
group: str | None = None,
config: Mapping[str, Any] | None = None,
step_metric: str = 'gepa/iteration',
key_prefix: str = 'gepa/',
attach_existing: bool = False,
**trackio_init_overrides: Any
) -> dict[str, Any]
make_gepa_tracking_config(
*,
project: str = 'fast-agent-gepa',
name: str | None = None,
group: str | None = None,
config: Mapping[str, Any] | None = None,
step_metric: str = 'gepa/iteration',
key_prefix: str = 'gepa/',
attach_existing: bool = False,
**trackio_init_overrides: Any
) -> Any
Evaluator metric helpers
gepa_numeric_metrics() flattens side_info['scores'],
side_info['score_details'], and side_info['raw_metrics'] into
Trackio-friendly numeric metrics. safe_trackio_log() logs them without
making Trackio a hard dependency of evaluator code.