PromptOptimizationFeature

Feature that applies an OptimizationArtifact to an agent at strategy start.

At strategy start, this feature:

  1. Stores the OptimizationArtifact in agent storage for optimizable subgraphs to read.

  2. Stores PromptInsertionDefaults in agent storage for subgraphs to inherit.

  3. If OptimizationArtifact.strategyInstruction is set, replaces the system message in the prompt with the optimized instruction.

  4. If OptimizationArtifact.strategyDemonstrations is non-empty, appends demonstrations after the system message.

Without this feature installed, optimizable subgraphs fall back to their default instructions and empty demonstrations.

Usage:

val agent = AIAgent(...) {
installPromptOptimization {
artifact = loadedArtifact
}
}

Properties

Link copied to clipboard
open override val key: AIAgentStorageKey<OptimizationArtifact>

Storage key under which the applied OptimizationArtifact is published.

Functions

Link copied to clipboard
open override fun createInitialConfig(agentConfig: AIAgentConfig): PromptPromptOptimizationFeatureConfig

Creates the default, empty PromptPromptOptimizationFeatureConfig.

Link copied to clipboard
open override fun install(config: PromptPromptOptimizationFeatureConfig, pipeline: AIAgentGraphPipeline): OptimizationArtifact

Registers the strategy-start interceptor that publishes the artifact and applies strategy-level prompt edits.