From 2fae8fba9c262b390a8d2c4c444165a8698e149a Mon Sep 17 00:00:00 2001 From: EloquentBrush0x <283442588+EloquentBrush0x@users.noreply.github.com> Date: Mon, 18 May 2026 18:22:48 +0300 Subject: [PATCH] fix(aux): strip pattern/format keywords from tool schemas on xAI Responses path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- agent/auxiliary_client.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py index ba78833248..a7c81c0b94 100644 --- a/agent/auxiliary_client.py +++ b/agent/auxiliary_client.py @@ -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 {}