← Back to PRs

#22175: fix: support xai tool stream and compat flags

by ShunsukeHayashi open 2026-02-20 20:45 View on GitHub →
agents size: XS
## Summary - Treat xai provider as z.ai-like for OpenAI-completions compatibility. - Apply default tool_stream=true for xai providers in pi-embedded-runner extra params. - Add regression tests for model-compat and tool_stream behavior. ## Why xAI via OpenClaw sometimes returned 403/streaming incompatibility due to missing Z.AI parity handling. ## Testing - Not run in this environment per instruction. <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR extends xAI (provider `"xai"`, baseUrl `api.x.ai`) to receive the same OpenAI-completions compatibility treatment previously limited to Z.AI (`"zai"`). Two specific behaviors are added: (1) `supportsDeveloperRole` is forced to `false` in `normalizeModelCompat`, and (2) `tool_stream=true` is injected by default in `applyExtraParamsToAgent`. Both changes are minimal, well-targeted, and consistent with existing patterns. - `model-compat.ts`: xAI models now get `supportsDeveloperRole: false` alongside Z.AI, fixing 403/streaming incompatibility - `extra-params.ts`: `tool_stream=true` is injected for `"xai"` provider, enabling real-time tool call streaming - Regression tests added for both behaviors, following existing test patterns - No issues found — the changes are clean and narrowly scoped <h3>Confidence Score: 5/5</h3> - This PR is safe to merge — it extends existing, well-tested behavior to a new provider with no architectural changes. - The changes are minimal and follow existing patterns exactly. The xai provider is already a first-class citizen in the codebase (onboarding, auth, model discovery). The two behavioral changes (compat flags and tool_stream) are narrowly scoped, well-tested, and match the proven zai implementation. No new APIs, no security implications, no breaking changes. - No files require special attention. <sub>Last reviewed commit: 2054ce8</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs