Skip to content
Tracon

InstructionParameterBinder

Namespace Tracon · Assembly Tracon.Core.dll

Substitutes {{name}} placeholders in an instructions text with concrete values.

public static class InstructionParameterBinder

objectInstructionParameterBinder

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

This is value substitution only, not a template engine. There is no expression, condition, loop, or field access ({{a.b}}) - deliberately: a template language is a security surface once it is in the library, and every consumer eventually wants their own dialect.

Substitution is single-pass. Regex.Replace scans the original text once; the text a match is replaced with is never re-scanned for further placeholders. A value that itself contains {{name}} is therefore inserted literally, not substituted again - this is what keeps binding from recursing.

JSON-safe escaping is context-aware, not unconditional. A placeholder written as a full JSON string value in the template - that is, immediately preceded and followed by a " character, as in "{{customer}}" - has its value JSON-escaped (quote, backslash, control characters) so the produced text stays valid JSON. A placeholder anywhere else in the text is substituted as-is: escaping it unconditionally would litter plain-text instructions with stray backslashes.

Bind(string?, IReadOnlyList<AgentParameter>, IReadOnlyDictionary<string, string>?)

Section titled “ Bind(string?, IReadOnlyList<AgentParameter>, IReadOnlyDictionary<string, string>?)”

Substitutes every placeholder in instructions with a concrete value.

public static string? Bind(string? instructions, IReadOnlyList<AgentParameter> schema, IReadOnlyDictionary<string, string>? values)

instructions string?

The template text. null or empty is returned unchanged.

schema IReadOnlyList<AgentParameter>

The parameter schema the placeholders must be declared in.

values IReadOnlyDictionary<string, string>?

The values supplied for this run. A schema entry missing from this dictionary falls back to its AgentParameter.DefaultValue, then to an empty string.

string?

The text with every declared placeholder substituted.

A placeholder whose name is not declared in schema is left untouched, literal braces and all - this method never fails. AgentParameterValidator is what rejects an undeclared placeholder, and it runs at compile time, before a value is ever bound.

ArgumentNullException

schema is null.