fix(schema_sanitizer): strip pattern/format from Responses-format tools for xAI compatibility#27219
Conversation
…ls for xAI compatibility Closes NousResearch#27197 Problem: strip_pattern_and_format() only walked OpenAI-format tool shapes ({"function": {"parameters": ...}}), missing Responses-format ({"name": ..., "parameters": ...}), leaving pattern/format in xAI /responses calls causing HTTP 400. Solution: 1. Extend strip_pattern_and_format() for Responses-format tools 2. Call it before codex_responses kwargs for xAI providers Tests: 29/29 passed (27 original + 2 new Responses-format tests) +156 chars in new test file
This comment was marked as spam.
This comment was marked as spam.
…d test for Responses-format
|
Thanks @cardtest15-coder for the thorough review! Addressed in
Regarding the |
This comment was marked as spam.
This comment was marked as spam.
|
@cardtest15-coder — proactively added mixed-format test in Looks like your follow-up ran into a Fireworks API 412 error. Once the API is back, feel free to re-review! 🚀 |
Port of the run_agent.py changes from #27219 to current main: the _build_api_kwargs body was extracted into agent/chat_completion_helpers. build_api_kwargs, so wire the xAI tool-schema sanitization there (provider in {'xai', 'xai-oauth'} or base_url=api.x.ai). Logs a warning instead of silently swallowing exceptions, matching the contributor's review-followup fix. Co-authored-by: zccyman <zccyman@163.com>
|
Thanks for this fix — landed in main via #27575 with your authorship preserved on the sanitizer commit. I ported your |
Port of the run_agent.py changes from NousResearch#27219 to current main: the _build_api_kwargs body was extracted into agent/chat_completion_helpers. build_api_kwargs, so wire the xAI tool-schema sanitization there (provider in {'xai', 'xai-oauth'} or base_url=api.x.ai). Logs a warning instead of silently swallowing exceptions, matching the contributor's review-followup fix. Co-authored-by: zccyman <zccyman@163.com>
Summary
strip_pattern_and_format() now handles Responses-format tool schemas ({\name: ..., \parameters: ...}) used by codex_responses API mode, plus auto-strips before xAI /responses calls.
Closes #27197
Problem
xAI's /responses endpoint rejects pattern and format keywords in tool schemas with HTTP 400. The existing strip_pattern_and_format() only walked OpenAI-format tools ({\function: {\parameters: ...}}), missing Responses-format shapes.
Solution
Files Changed
Test Results
tests/tools/test_schema_sanitizer.py ✓ 29 passed in 3.61s