mod capability#

module capability#

Capability registry tracking per-backend and per-model-family supported features.

The registry provides feature discovery so the policy engine knows which optimization intents can be expressed on which backend/model combinations.

Two-Level Feature Lookup

BackendCapabilities stores backend-level defaults plus per-model-family overrides via ModelFamilyCapabilities. Feature lookups check the model family first, falling back to backend-level if the family is not registered.

Built-in Defaults

CapabilityRegistry::with_defaults() returns a registry pre-populated with known Anthropic and OpenAI capabilities.

Enums

enum ProviderFeature#

Feature that a backend or model family may support.

Used by the capability registry and policy engine to determine which optimization intents can be expressed for a given target.

ExplicitCacheBreakpoints#

Backend supports explicit cache control breakpoints (e.g., Anthropic).

AutomaticPrefixCaching#

Backend uses automatic prefix caching (e.g., OpenAI).

RetentionTiers#

Backend supports retention tier control.

PriorityScheduling#

Backend supports priority-based scheduling.

ModelRouting#

Backend supports model routing/selection.

DeferredToolLoading#

Backend supports deferred tool loading.

FileReferences#

Backend supports file/artifact references in prompts.

StructuredOutput#

Backend supports structured output schemas.

PrefixAffinityHints#

Backend supports prefix-affinity routing hints.

StreamingTokenCounts#

Backend reports per-chunk token counts in streaming responses.

Structs and Unions

struct BackendCapabilities#

Capabilities of a specific backend provider.

Two-level model: backend-level defaults plus per-model-family overrides. Feature lookup checks model-family first, falls back to backend-level.

backend_id: String#

Backend identifier (e.g., “anthropic”, “openai”, “passthrough”).

supported_features: HashSet<ProviderFeature>#

Backend-level supported features (default for all models).

model_families: HashMap<String, ModelFamilyCapabilities>#

Per-model-family capability overrides.

Implementations

impl BackendCapabilities#

Functions

fn add_model_family(&mut self, caps: ModelFamilyCapabilities)#

Add a model family capability override.

fn model_supports(&self, model_family: &str, feature: ProviderFeature) -> bool#

Check if a specific model family supports a feature.

Falls back to backend-level if the model family is not registered.

fn none(backend_id: &str) -> Self#

Create capabilities with no features (used by passthrough plugin).

fn supports(&self, feature: ProviderFeature) -> bool#

Check if the backend supports a feature at the backend level.

struct CacheEconomics#

Provider/model-specific cache economics used by the internal planner.

These values are kept on the capability surface so the core planner can stay provider-agnostic while concrete plugins/model families supply the pricing model that makes a cache write profitable.

write_short_multiplier: f64#

Input cost multiplier for creating a short-lived cache entry.

write_long_multiplier: Option<f64>#

Optional input cost multiplier for creating a longer-lived cache entry.

read_multiplier: f64#

Input cost multiplier for reading from cache.

Implementations

impl CacheEconomics#
struct CapabilityRegistry#

Registry holding capabilities for all known backends.

Provides feature discovery so the policy engine and validation framework know which intents can be expressed on which targets.

Implementations

impl CapabilityRegistry#

Functions

fn get_backend(&self, backend_id: &str) -> Option<&BackendCapabilities>#

Retrieve a backend’s capabilities by ID.

fn list_backend_ids(&self) -> Vec<String>#

Return a sorted list of all registered backend IDs.

fn model_supports_feature(&self, backend_id: &str, model_family: &str, feature: ProviderFeature) -> bool#

Check if a specific model family on a backend supports a feature.

Falls back to backend-level if the model family is not registered.

fn new() -> Self#

Create a new empty capability registry.

fn register_backend(&mut self, caps: BackendCapabilities)#

Register a backend’s capabilities in the registry.

fn supports_feature(&self, backend_id: &str, feature: ProviderFeature) -> bool#

Check if a backend supports a feature at the backend level.

fn with_defaults() -> Self#

Create a registry pre-populated with known Anthropic and OpenAI capabilities.

struct ModelFamilyCapabilities#

Per-model-family capability overrides within a backend.

Some features vary by model within the same backend (e.g., Claude 3.5 Sonnet supports 4 cache breakpoints while older models support fewer).

model_family: String#

Model family identifier (e.g., “claude-3.5-sonnet”, “gpt-4o”).

supported_features: HashSet<ProviderFeature>#

Features supported by this model family.

max_cache_breakpoints: Option<u32>#

Maximum number of cache breakpoints (if applicable).

min_cacheable_tokens: Option<u32>#

Minimum tokens required for a block to be cacheable.

cache_economics: Option<CacheEconomics>#

Provider/model-specific cache economics for explicit cache planning.

Implementations

impl ModelFamilyCapabilities#

Functions

fn supports(&self, feature: ProviderFeature) -> bool#

Check if this model family supports a specific feature.