Repository navigation
refactor(xai): share responses tool request transport - #128571
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 2:59 AM ET / 06:59 UTC. ClawSweeper reviewWhat this changesThe PR centralizes xAI Responses request transport and bounded JSON parsing for web search, X search, and code execution. Merge readinessNo blocking source-level finding was identified. The protected Priority: P3 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe bundled xAI provider turns agent tool requests into xAI Responses API calls, then parses and projects bounded results back into agent tool flows. flowchart LR
A[Agent tool request] --> B[xAI capability owner]
B --> C[Shared Responses transport]
C --> D[xAI Responses API]
D --> E[Bounded response parsing]
E --> F[Search or code result]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -17, Tests -35, Other -1. Total -53 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one private xAI transport owner and land only after the outstanding exact-head checks confirm this behavior-preserving refactor. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR refactors existing private transport rather than reporting a user-facing defect. Is this the best way to solve the issue? Yes: the private xAI Responses owner is the narrowest shared boundary while each capability keeps its own endpoint, cancellation, output, and response policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 68c48422cc6e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
* refactor(xai): share responses tool request transport * refactor(xai): remove unused responses body test seam * test(xai): preserve responses request contracts at fetch boundaries
What Problem This Solves
The xAI web search, X search, and code execution tools each maintained their own copies of the same guarded Responses request and bounded JSON parsing. Repeating that provider-owned transport across sibling capabilities made their request, error, and cancellation contracts harder to keep consistent.
Why This Change Was Made
Move the identical request and bounded-response parsing into the existing private xAI Responses owner, then route all three sibling capabilities through it. Keep capability-specific endpoint selection, reasoning effort, output limits, cancellation, timeout presentation, and response projection with their existing owners. Remove the now-unnecessary code-execution response alias.
User Impact
No user-visible behavior changes. Existing xAI search and code-execution capabilities retain their exact authentication, request payloads, errors, cancellation, sanitization, citation bounds, and output behavior while the provider implementation has fewer duplicate paths.
Evidence
OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-cleanup-lane3-vitest-cache node scripts/run-vitest.mjs --configLoader runner extensions/xai/web-search.test.ts extensions/xai/x-search.test.ts extensions/xai/code-execution.test.ts extensions/xai/src/responses-tool-shared.test.tsenv -u OPENCLAW_TESTBOX OPENCLAW_LOCAL_CHECK=1 node scripts/check-changed.mjs -- extensions/xai/src/responses-tool-shared.ts extensions/xai/src/web-search-shared.ts extensions/xai/src/x-search-shared.ts extensions/xai/src/code-execution-shared.ts.