

























@@ -3,6 +3,7 @@ import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/st
33import { splitTrailingAuthProfile } from "../../agents/model-ref-profile.js";
44import { isModelKeyAllowedBySet } from "../../agents/model-selection-shared.js";
556+/** Alias lookup tables used by `/model` directive resolution. */
67export type ModelAliasIndex = {
78byAlias: Map<
89string,
@@ -14,6 +15,7 @@ export type ModelAliasIndex = {
1415byKey: Map<string, string[]>;
1516};
161718+/** Resolved model choice from a `/model` directive. */
1719export type ModelDirectiveSelection = {
1820provider: string;
1921model: string;
@@ -56,6 +58,7 @@ const FUZZY_VARIANT_TOKENS = [
5658"nano",
5759];
586061+/** Builds the canonical provider/model key used by allowlists and aliases. */
5962export function modelKey(provider: string, model: string): string {
6063const providerId = provider.trim();
6164const modelId = model.trim();
@@ -72,6 +75,7 @@ export function modelKey(provider: string, model: string): string {
7275 : `${providerId}/${modelId}`;
7376}
747778+/** Resolves an explicit model directive string into a provider/model ref. */
7579export function resolveModelRefFromDirectiveString(params: {
7680raw: string;
7781defaultProvider: string;
@@ -260,6 +264,7 @@ function scoreFuzzyMatch(params: {
260264};
261265}
262266267+/** Resolves a `/model` directive into an allowlisted model selection or error. */
263268export function resolveModelDirectiveSelection(params: {
264269raw: string;
265270defaultProvider: string;
@@ -356,6 +361,7 @@ export function resolveModelDirectiveSelection(params: {
356361return Object.assign({ candidate }, details);
357362})
358363.toSorted((a, b) => {
364+// Tie-break deterministically so repeated prompts pick the same model.
359365if (b.score !== a.score) {
360366return b.score - a.score;
361367}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。