ChatOptionsMerge

Helpers & Utilities · AiDotNet.Agentic.Pipeline

Layers chat settings so a specific setting wins over a general one, field by field.

For Beginners

Suppose you set a default temperature for all your models, a different one for one particular model, and a third for a single call. Which wins? The most specific one that you actually set: the call beats the model, the model beats the global default, and anything you left blank falls through to the next level down. This helper does that combining for you.

How It Works

Chat settings arrive from several places at once: the per-call options a caller passes, the defaults attached to one ensemble member, the defaults attached to the whole client, and finally whatever the connector does when a value is left unset. Because every property of ChatOptions is nullable, “unset” and “explicitly set” are distinguishable, and layering is a simple field-wise choice: take the value from the most specific layer that supplied one.

Merging happens at call time, which matters. The reference OpenEvolve implementation copies shared settings into each model’s configuration once, during construction, from a hard-coded list of field names — so a model added to the ensemble afterwards silently keeps null settings, and a field added to the configuration type but not to that list is never propagated at all. Layering at the point of use has neither failure mode.

Methods

Method Summary
ChatOptions Copy(ChatOptions options) Creates an independent copy of a set of settings.
ChatOptions Merge(ChatOptions primary, ChatOptions fallback) Layers two sets of settings, preferring the more specific one field by field.
ChatOptions Merge(ChatOptions primary, ChatOptions secondary, ChatOptions tertiary) Layers three sets of settings, most specific first.