


























@@ -20,6 +20,29 @@ export type ModelDirectiveSelection = {
2020alias?: string;
2121};
222223+function formatAddModelCommand(modelRef: string): string {
24+return `openclaw config set agents.defaults.models '${JSON.stringify({ [modelRef]: {} })}' --strict-json --merge`;
25+}
26+27+function formatNotAllowedError(params: {
28+modelRef: string;
29+rawRuntime?: string | undefined;
30+}): string {
31+const rawRuntime = params.rawRuntime?.trim();
32+const retryCommand = rawRuntime
33+ ? `/model ${params.modelRef} --runtime ${rawRuntime}`
34+ : `/model ${params.modelRef}`;
35+const lines = [
36+`Model "${params.modelRef}" is not allowed. Use /models to list providers, or /models <provider> to list models.`,
37+`Add it with: ${formatAddModelCommand(params.modelRef)}`,
38+`Then retry: ${retryCommand}`,
39+];
40+if (rawRuntime && normalizeProviderId(rawRuntime) === "codex") {
41+lines.push("If the Codex runtime is missing, run: openclaw plugins enable codex");
42+}
43+return lines.join("\n");
44+}
45+2346const FUZZY_VARIANT_TOKENS = [
2447"lightning",
2548"preview",
@@ -238,6 +261,7 @@ export function resolveModelDirectiveSelection(params: {
238261defaultModel: string;
239262aliasIndex: ModelAliasIndex;
240263allowedModelKeys: Set<string>;
264+rawRuntime?: string | undefined;
241265}): { selection?: ModelDirectiveSelection; error?: string } {
242266const { raw, defaultProvider, defaultModel, aliasIndex, allowedModelKeys } = params;
243267@@ -401,6 +425,9 @@ export function resolveModelDirectiveSelection(params: {
401425}
402426403427return {
404-error: `Model "${resolved.ref.provider}/${resolved.ref.model}" is not allowed. Use /models to list providers, or /models <provider> to list models.`,
428+error: formatNotAllowedError({
429+modelRef: `${resolved.ref.provider}/${resolved.ref.model}`,
430+rawRuntime: params.rawRuntime,
431+}),
405432};
406433}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。