fix(aux): strip pattern/format keywords from tool schemas on xAI Responses path

xAI's /responses endpoint rejects tool schemas that contain pattern or
format JSON Schema keywords with HTTP 400. chat_completion_helpers.py
already strips these for the main-agent xAI/xai-oauth path (lines
294-302), but _CodexCompletionsAdapter.create() — used for every xAI
OAuth auxiliary call (kanban decomposer, profile describer, etc.) —
passed raw tool schemas without sanitization.

MCP tools that carry pattern/format keywords (common for string fields)
silently caused every auxiliary call over xAI OAuth to fail with an
HTTP 400, while the main agent worked fine. Parity fix: call
strip_pattern_and_format() on the tool list before converting to
Responses API format, matching the main-agent guarantee.
This commit is contained in:
EloquentBrush0x
2026-05-18 18:22:48 +03:00
committed by Teknium
parent 502d03d5a3
commit 2fae8fba9c
+8
View File
@@ -707,6 +707,14 @@ class _CodexCompletionsAdapter:
# Tools support for auxiliary callers (e.g. skills_hub) that pass function schemas
tools = kwargs.get("tools")
if tools:
# xAI's Responses endpoint rejects ``pattern`` and ``format`` JSON Schema
# keywords (HTTP 400). Strip them here to match the parity guarantee that
# chat_completion_helpers.py provides for the main-agent xAI path.
try:
from tools.schema_sanitizer import strip_pattern_and_format
tools, _ = strip_pattern_and_format(list(tools))
except Exception:
pass
converted = []
for t in tools:
fn = t.get("function", {}) if isinstance(t, dict) else {}