mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 21:03:43 +00:00
fix(tools): strip xAI-unsupported JSON Schema keywords from tool definitions
xAI rejects minLength, maxLength, minItems, maxItems, minContains, and maxContains in tool schemas with a 502 error instead of ignoring them. This causes all requests to fail when any tool definition includes these validation-constraint keywords (e.g. sessions_spawn uses maxLength and maxItems on its attachment fields). Add stripXaiUnsupportedKeywords() in schema/clean-for-xai.ts, mirroring the existing cleanSchemaForGemini() pattern. Apply it in normalizeToolParameters() when the provider is xai directly, or openrouter with an x-ai/* model id. Fixes tool calls for x-ai/grok-* models both direct and via OpenRouter.
This commit is contained in:
committed by
Peter Steinberger
parent
da05395c2a
commit
00347bda75
@@ -524,7 +524,10 @@ export function createOpenClawCodingTools(options?: {
|
||||
// Without this, some providers (notably OpenAI) will reject root-level union schemas.
|
||||
// Provider-specific cleaning: Gemini needs constraint keywords stripped, but Anthropic expects them.
|
||||
const normalized = subagentFiltered.map((tool) =>
|
||||
normalizeToolParameters(tool, { modelProvider: options?.modelProvider }),
|
||||
normalizeToolParameters(tool, {
|
||||
modelProvider: options?.modelProvider,
|
||||
modelId: options?.modelId,
|
||||
}),
|
||||
);
|
||||
const withHooks = normalized.map((tool) =>
|
||||
wrapToolWithBeforeToolCallHook(tool, {
|
||||
|
||||
Reference in New Issue
Block a user