Agentic.ModelRouter.Preference (agentic v0.2.2)

Copy Markdown

Defines model selection preferences and the scoring logic for each.

User preferences control how the Selector ranks candidate models:

  • :optimize_price — prefer cheaper models; only upgrade when the analysis demands it (complex tasks, vision, etc.)
  • :optimize_speed — prefer faster models; prioritize throughput and low latency, willing to spend more

The preference is combined with an Analyzer.analysis() result to produce a scoring function used by Selector.rank/3.

Summary

Functions

Return the default preference.

Parse a preference from user input.

Compute a score for a model given a preference and analysis.

Types

preference()

@type preference() :: :optimize_price | :optimize_speed

Functions

default()

@spec default() :: preference()

Return the default preference.

parse(other)

@spec parse(term()) :: {:ok, preference()} | {:error, term()}

Parse a preference from user input.

score(model, preference, analysis)

Compute a score for a model given a preference and analysis.

Lower scores are better. The scoring considers:

  • Base cost or speed rating
  • Complexity-appropriate tier matching
  • Capability matching (vision, reasoning, etc.)
  • Penalty for missing required capabilities