fix(xai): reject unsupported multi-agent model refs before runtime fallback

This commit is contained in:
xialonglee
2026-06-17 13:25:48 +08:00
committed by Peter Steinberger
parent aea208f0ac
commit e29576d25f
2 changed files with 20 additions and 1 deletions

View File

@@ -262,6 +262,12 @@ export default defineSingleProviderPluginEntry({
resolveThinkingProfile,
isModernModelRef: ({ modelId }) => isModernXaiModel(modelId),
classifyFailoverReason: ({ errorMessage }) => classifyXaiFailoverReason(errorMessage),
buildUnknownModelHint: ({ modelId }) => {
if (modelId.toLowerCase().includes("multi-agent")) {
return "xAI multi-agent models are not supported on the standard xAI API-key provider path. See https://docs.openclaw.ai/providers/xai for supported models.";
}
return undefined;
},
},
register(api) {
api.registerWebSearchProvider(createXaiWebSearchProvider());

View File

@@ -522,6 +522,7 @@ function mergeStaticCatalogInlineModel(
}
function hasConfiguredFallbackSurface(params: {
provider?: string;
providerConfig: InlineProviderConfig | undefined;
configuredModel: ReturnType<typeof findConfiguredProviderModel>;
modelId: string;
@@ -532,6 +533,18 @@ function hasConfiguredFallbackSurface(params: {
if (params.configuredModel) {
return true;
}
// xAI's catalog explicitly excludes multi-agent model ids (they require a
// different upstream API surface than the standard API-key provider path).
// If the provider rejected this model via its dynamic resolution, do not
// synthesize a configured-provider fallback that will silently 400.
// See: https://docs.openclaw.ai/providers/xai
if (
params.provider &&
normalizeProviderId(params.provider) === "xai" &&
params.modelId.toLowerCase().includes("multi-agent")
) {
return false;
}
const baseUrl = params.providerConfig?.baseUrl?.trim();
return Boolean(baseUrl);
}
@@ -1245,7 +1258,7 @@ function resolveConfiguredFallbackModel(params: {
const providerConfig = resolveConfiguredProviderConfig(cfg, provider);
const requestTimeoutMs = resolveProviderRequestTimeoutMs(providerConfig?.timeoutSeconds);
const configuredModel = findConfiguredProviderModel(providerConfig, provider, modelId);
if (!hasConfiguredFallbackSurface({ providerConfig, configuredModel, modelId })) {
if (!hasConfiguredFallbackSurface({ provider, providerConfig, configuredModel, modelId })) {
return undefined;
}
const staticCatalogModel = resolveBundledStaticCatalogModel({