Graphorin API reference v0.7.0
Graphorin API reference / @graphorin/agent / preferred-model
preferred-model
Per-tool / per-agent preferred-model resolution. Pure functions consulted by the agent loop AFTER the model has decided which tool(s) to call but BEFORE provider.stream(...) is invoked.
The four-step precedence ladder (highest wins):
prepareStep({ provider })- the operator's explicit per-step override always wins.Tool.preferredModel- the tool author's per-tool hint. Only the tools the model actually CALLED on the previous step are consulted (AG-15) - an advertised-but-uncalled hint never escalates the run. Multi-tool ties resolve to the highest cost tier ('smart' > 'balanced' > 'fast'; explicitModelSpecis treated as the highest tier).Agent.preferredModel?- the per-agent default.Agentdefaultprovider- the v0.1-alpha behaviour.
Cost-tier resolution against Agent.modelTierMap is documented as a hint: when the requested tier is unmapped, the resolver falls through to the next precedence step rather than throwing.
Interfaces
| Interface | Description |
|---|---|
| PreferredModelResolution | Result returned by resolvePreferredModel. |
| ResolvePreferredModelInput | Pure inputs to resolvePreferredModel. |
Functions
| Function | Description |
|---|---|
| pickTopTierAcrossTools | Pick the highest-cost tier across the supplied per-tool hints. Explicit ModelSpec entries are treated as the highest tier ('smart') for tie-breaking - the conservative-correctness rule documented in DEC-169 / suggested ADR-057. |
| resolvePreferredModel | Walk the precedence ladder and return the resolved provider for a single agent step. Pure function - no side effects. |