Skip to content

refactor(xai): share responses tool request transport - #128571

Merged
steipete merged 3 commits into
mainfrom
codex/cleanup-lane3-20260823
Aug 24, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/cleanup-lane3-20260823

Conversation

@steipete

Copy link
Copy Markdown
Contributor

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

  • Production: +57/-74, net -17 lines across four private xAI provider modules; tests: unchanged.
  • Assertion-safety baseline: three grandfathered unchecked type assertions removed; the required baseline ratchet decreases by exactly those three violations.
  • Focused owner-boundary proof: 4 test files and 100 tests passed, covering web search, X search, code execution, malformed/oversized responses, hostile citations, timeout errors, cancellation identity, request bodies, and authentication.
  • 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.ts
  • Changed-gate command: env -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.
  • A complete local changed gate is unavailable because the task worktree must reuse a stale, independently owned dependency tree with mismatched workspace links and package versions. Exact-head hosted PR CI and the mandatory Testbox-backed maintainer preparation are the clean-source full validation gates.
  • Structured autoreview: clean, with no accepted or actionable findings.
  • Two independent source reviews verified unchanged guarded transport, bounded JSON parsing, exact provider labels, timeout and abort behavior, search-only output caps, citation handling, and code-execution response projection.
  • No public API, provider model, plugin manifest, configuration, security policy, or dependency changes. Existing fetch-boundary tests use controlled provider responses; no live external provider request was needed for this behavior-preserving internal refactor.

@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 24, 2026 06:35
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 24, 2026
@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 2:59 AM ET / 06:59 UTC.

ClawSweeper review

What this changes

The PR centralizes xAI Responses request transport and bounded JSON parsing for web search, X search, and code execution.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking source-level finding was identified. The protected maintainer PR should remain open for its exact-head CI gate, not automated cleanup.

Priority: P3
Reviewed head: f80a6cec2ebd7815fd8be6a2245095b1eb44e00e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative owner-boundary refactor with preserved capability-level coverage and no source-level finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-owned behavior-preserving refactor is exempt from the external-contributor proof gate; the PR body supplies controlled fetch-boundary test results.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-owned behavior-preserving refactor is exempt from the external-contributor proof gate; the PR body supplies controlled fetch-boundary test results.
Evidence reviewed 6 items Shared owner checked: The private helper builds the Responses body, retains guarded POST transport, and passes each capability’s parsing label into bounded JSON parsing.
Sibling paths checked: Web search, X search, and code execution retain their respective endpoint, reasoning, cancellation, output-limit, and projection policies while delegating transport only.
SDK transport contract checked: The existing SDK transport accepts the endpoint, timeout, abort signal, bearer credential, and JSON body supplied by the new shared helper.
Findings None None.
Security None None.

Live Verification

Command: 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.ts

Result: PASS (completed)

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 extens
ions/xai/src/responses-tool-shared.test.tsrunner@runnervm76f27:/tmp/clawsweeper-live-proof-128571-trvsEH/target$ node scripts/run-vitest.mjs --configLoader runn
er 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.ts
[test] starting test/vitest/vitest.extension-providers.config.ts
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 extens
ions/xai/src/responses-tool-shared.test.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128571-trvsEH/target

 ✓  extension-providers  extensions/xai/src/responses-tool-shared.test.ts (17 tests) 224ms
 ✓  extension-providers  extensions/xai/code-execution.test.ts (7 tests) 51ms
 ✓  extension-providers  extensions/xai/x-search.test.ts (23 tests) 152ms
 ✓  extension-providers  extensions/xai/web-search.test.ts (51 tests) 99ms

 Test Files  4 passed (4)
      Tests  98 passed (98)
   Start at  06:59:53
   Duration  27.11s (transform 36.04s, setup 4.68s, import 43.52s, tests 526ms, environment 0ms)

































Assertions:

  • PASS expect_output: Test Files

How this fits together

The 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]
Loading

Before merge

  • Resolve merge risk (P1) - The supplied PR state still has exact-head checks in progress; do not merge until they finish green.
  • Complete next step (P2) - This is a protected maintainer PR with no concrete mechanical repair identified; wait for normal exact-head CI completion.
Agent review details

Security

None.

PR surface

Source -17, Tests -35, Other -1. Total -53 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 4 58 75 -17
Tests 1 0 35 -35
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 3 -1
Total 6 60 113 -53

Review metrics

Metric Value Why it matters
Production versus test LOC production +58/-75 (net -17); tests 0/-35; assertion baseline +2/-3 The refactor removes duplicated private transport while deleting only obsolete direct-helper coverage; capability-boundary tests remain.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one private xAI transport owner and land only after the outstanding exact-head checks confirm this behavior-preserving refactor.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best 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.

Labels

Label changes:

  • add P3: This is a small internal provider refactor with no claimed user-visible behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-owned behavior-preserving refactor is exempt from the external-contributor proof gate; the PR body supplies controlled fetch-boundary test results.

Label justifications:

  • P3: This is a small internal provider refactor with no claimed user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-owned behavior-preserving refactor is exempt from the external-contributor proof gate; the PR body supplies controlled fetch-boundary test results.

Evidence

What I checked:

  • Shared owner checked: The private helper builds the Responses body, retains guarded POST transport, and passes each capability’s parsing label into bounded JSON parsing. (extensions/xai/src/responses-tool-shared.ts:77, f80a6cec2ebd)
  • Sibling paths checked: Web search, X search, and code execution retain their respective endpoint, reasoning, cancellation, output-limit, and projection policies while delegating transport only. (extensions/xai/src/web-search-shared.ts:100, f80a6cec2ebd)
  • SDK transport contract checked: The existing SDK transport accepts the endpoint, timeout, abort signal, bearer credential, and JSON body supplied by the new shared helper. (src/agents/tools/web-search-provider-common.ts:132, f80a6cec2ebd)
  • Tests and test-audit checked: Capability-boundary tests retain request-body, malformed-response, timeout, cancellation, and result-projection coverage; removing direct coverage of the now-private body helper avoids an implementation-coupled seam. (extensions/xai/x-search.test.ts:236, f80a6cec2ebd)
  • Feature-history routing: Feature history identifies Peter Steinberger as the recent owner of the xAI Responses parsing path, including the all-text-and-citations repair. (extensions/xai/src/responses-tool-shared.ts:77, 8a5cfa4caca7)
  • Current-main inspection limitation: The local partial clone could not materialize requested current-main comparison objects because its promisor remote was unreachable; this review does not claim a direct current-main file comparison.

Likely related people:

  • steipete: Authored the current refactor and the prior xAI Responses text/citation repair found in feature history. (role: recent provider owner; confidence: high; commits: f80a6cec2ebd, 8a5cfa4caca7; files: extensions/xai/src/responses-tool-shared.ts, extensions/xai/src/web-search-shared.ts, extensions/xai/src/x-search-shared.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the supplied exact-head required checks complete successfully before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 68ba1ef into main Aug 24, 2026
153 checks passed
@steipete
steipete deleted the codex/cleanup-lane3-20260823 branch August 24, 2026 07:57
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 25, 2026
* refactor(xai): share responses tool request transport

* refactor(xai): remove unused responses body test seam

* test(xai): preserve responses request contracts at fetch boundaries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: xai maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant