#22175: fix: support xai tool stream and compat flags
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
#11561: fix: respect supportsReasoningEffort compat flag for xAI/Grok reaso...
by baxter-lindsaar · 2026-02-08
77.9%
#23655: fix(model): map developer role to system for Aliyun/Dashscope/Qianf...
by SleuthCo · 2026-02-22
76.8%
#14187: fix: add Moonshot AI to non-standard provider detection
by shad0wca7 · 2026-02-11
76.8%
#12248: fix: wire streaming config field through resolveExtraParams to stre...
by mcaxtr · 2026-02-09
76.1%
#9339: fix: enhance OpenAI compatibility for tool calling
by 0xrushi · 2026-02-05
75.2%
#21720: fix(#21546): OpenAI conditional tool-first prompt
by RonySpark · 2026-02-20
75.1%
#19384: Auto-reply: allow xhigh for OpenAI-compatible provider aliases
by 0x4007 · 2026-02-17
75.1%
#19281: fix: set supportsDeveloperRole false as default for moonshot provider
by MisterGuy420 · 2026-02-17
74.2%
#23549: fix: extend repairToolUseResultPairing and allowSyntheticToolResult...
by imjszhang · 2026-02-22
73.8%
#19394: fix(agents): normalize tool call arguments dropped to {} (#19261)
by DevvGwardo · 2026-02-17
73.7%