Path: redb-route/redb.Route.Llm.Abstractions/Tools/ExposeAsLlmToolAttribute.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.Abstractions/Tools/ExposeAsLlmToolAttribute.cs ---- namespace redb.Route.Llm.Abstractions.Tools; /// /// Marks a class, method, or route definition as exposable to an LLM as a tool. /// Discovered by the engine's tool registrars; the attribute carries the same /// metadata as so a descriptor can be built /// without reflecting on the handler body. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] public sealed class ExposeAsLlmToolAttribute : Attribute { /// Stable tool name used by the model. Required. public string Name { get; } /// Human-readable tool description shown to the model. Required. public string Description { get; } /// JSON Schema string for input parameters. Optional — when omitted the engine assigns a permissive object schema. public string? InputSchema { get; init; } /// Side-effect classification. Drives approval and idempotency policies. public ToolSideEffect SideEffect { get; init; } = ToolSideEffect.ReadOnly; /// Cost class hint for budget-aware scheduling. public ToolCostClass Cost { get; init; } = ToolCostClass.Cheap; /// Caching policy hint. public ToolCachingPolicy Caching { get; init; } = ToolCachingPolicy.None; /// When true the tool always requires explicit user approval before execution. public bool RequiresApproval { get; init; } /// /// Comma-separated list of claims required on the calling principal. Empty = no requirements. /// Enforced — the engine verifies the requirement against the registered /// IToolClaimsSource and refuses the call when it cannot. /// public string RequiredClaims { get; init; } = ""; /// Creates a tool exposure attribute. /// Stable tool name (regex [a-zA-Z][a-zA-Z0-9_]{0,63}). /// Human-readable description for the model. public ExposeAsLlmToolAttribute(string name, string description) { Name = name; Description = description; } /// Builds an from this attribute, applying /// when is null. public LlmToolCapability ToCapability(string defaultInputSchema) => new() { Name = Name, Description = Description, InputSchema = InputSchema ?? defaultInputSchema, Safety = new LlmToolSafety { SideEffect = SideEffect, Cost = Cost, Caching = Caching, RequiresApproval = RequiresApproval, RequiredClaims = string.IsNullOrWhiteSpace(RequiredClaims) ? [] : RequiredClaims .Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) } }; }