Path: redb-route/redb.Route.Llm/Expressions/LlmExpressionResolverSetup.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Llm/Expressions/LlmExpressionResolverSetup.cs ---- using System; using System.Reflection; using redb.Route.Abstractions; using redb.Route.Expressions; namespace redb.Route.Llm.Expressions; /// /// Registers ${conversation.*} and ${tool.*} resolvers with /// . The resolvers read the well-known /// exchange properties published by /// (, ) /// and walk the requested path via reflection — so adding fields to /// / /// automatically makes them available in templates. /// public static class LlmExpressionResolverSetup { private static int _initialized; /// /// Idempotently registers the LLM prefix resolvers. Safe to call from /// every host's composition root — subsequent calls are no-ops. /// public static void EnsureRegistered() { if (System.Threading.Interlocked.CompareExchange(ref _initialized, 1, 0) != 0) return; ExpressionResolver.RegisterPrefixResolver("conversation.", (exchange, path) => ResolvePath(exchange.getProperty(LlmExpressionKeys.Conversation), path)); ExpressionResolver.RegisterPrefixResolver("tool.", (exchange, path) => ResolvePath(exchange.getProperty(LlmExpressionKeys.Tool), path)); } private static object? ResolvePath(object? root, string path) { if (root is null || string.IsNullOrEmpty(path)) return root; var current = root; foreach (var part in path.Split('.', StringSplitOptions.RemoveEmptyEntries)) { if (current is null) return null; var type = current.GetType(); var prop = type.GetProperty(part, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase); if (prop is not null) { current = prop.GetValue(current); continue; } var field = type.GetField(part, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase); if (field is not null) { current = field.GetValue(current); continue; } return null; } return current; } }