BootstrapFewShotOptimizer

class BootstrapFewShotOptimizer<Input, Output, InputLabel>(val maxBootstrappedDemos: Int, val maxRounds: Int, val maxTotalDemos: Int, val includeLabeledExamples: Boolean, val storagePath: ResilientPath, randomSeed: Long) : AgentOptimizer<Input, Output, InputLabel>

Bootstrap few-shot optimizer that collects execution traces from successful agent runs and produces an OptimizationArtifact with demonstrations at both strategy and subgraph levels.

For each training example, the agent is run up to maxRounds times. On success, the optimizer collects:

  • Strategy-level demos: full agent trajectory (via trace collection feature), with the inherited system prompt prefix stripped.

  • Per-subgraph demos: traces from each optimizable subgraph, automatically collected when the strategy uses optimizableSubgraphWithTask.

The resulting OptimizationArtifact is saved to storagePath and applied to the agent via installPromptOptimization for inference.

Parameters

maxBootstrappedDemos

Maximum number of successful traces to collect.

maxRounds

Maximum retry attempts per training example.

maxTotalDemos

Total demo slots (bootstrapped and labeled fallback).

includeLabeledExamples

Whether to fill the remaining slots with labeled dataset items.

storagePath

File path to save/load the optimization artifact.

randomSeed

Seed for reproducible sampling.

Constructors

Link copied to clipboard
constructor(maxBootstrappedDemos: Int, maxRounds: Int, maxTotalDemos: Int, includeLabeledExamples: Boolean, storagePath: ResilientPath, randomSeed: Long)

Types

Link copied to clipboard
object Companion

Persistence helpers for the bootstrapped OptimizationArtifact.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open override fun loadOptimizedAgent(baseAgent: GraphAIAgent<Input, Output>): GraphAIAgent<Input, Output>

Loads training artifacts produced by train and applies them to the given baseAgent.

Link copied to clipboard
open suspend override fun train(session: TrainingSession<Input, Output, InputLabel>): TrainingResult

Trains the agent using the provided session, which gives access to a TrainingSession.use block where the training scope (agent, dataset, tracked execution methods) is available.