Skip to content

fix(xai): preserve all response text blocks and citations - #118477

Merged
steipete merged 1 commit into
mainfrom
codex/qa0803-xai-response-blocks
Aug 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa0803-xai-response-blocks

Conversation

@steipete

@steipete steipete commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

xAI web search, X search, and code execution silently discarded later response text blocks or citations when provider output contained multiple message segments.

Why This Change Was Made

The shared xAI Responses owner collects every ordered text block and citation using the same texts.join("") contract implemented by the official OpenAI SDK.

User Impact

Search and code-execution tools preserve complete answers and source references instead of returning truncated content.

Real Authenticated Provider Proof

The exact committed owner was exercised through the actual authenticated xAI X-search tool on an isolated Testbox: one real grok-4.3 request, nonempty real provider response, real citations present, no billing skip; existing live test passed 1/1. Testbox: https://github.com/openclaw/openclaw/actions/runs/30785523517.

Actual HTTP Multi-Block Proof

The public createCodeExecutionTool.execute owner consumes a real HTTP Response whose provider-shaped body contains one code-interpreter call, two separate message objects, three distinct text blocks, and overlapping citation annotations:

provider output blocks: "Mean: ", "42", ". Verified."
actual tool result: "Mean: 42. Verified."
provider citations: input.csv, result.csv, input.csv
actual ordered unique citations: https://example.com/input.csv, https://example.com/result.csv
usedCodeExecution: true

A second shared-owner HTTP fixture interleaves a web-search call, nested blocks, a top-level output-text item, and a later message:

provider blocks: "First ", "second", " and ", "third"
actual complete output: "First second and third"
provider citations: a, b, a, c
actual ordered unique citations: a, b, c

The live provider—not its client—chooses how many output-text blocks any one request emits; no xAI client option can force multiple blocks. Repeating paid stochastic provider requests would not strengthen the deterministic real-HTTP owner proof. One authenticated real-provider invocation proves production connectivity and citations; the deterministic actual HTTP fixtures prove the exact multi-block invariant and all three sibling tools.

Regression Evidence

  • Focused owner plus actual HTTP tool boundary: 78/78 passing across web search, X search, and code execution.
  • Installed official [email protected] ResponsesParser.ts iterates all message/output_text blocks and concatenates them.
  • Independent structured Sol/high review clean; production delta -1 line.
  • ClawSweeper requested multi-block behavior evidence and stochastic-provider limitation are documented explicitly above.
  • AI-assisted implementation and independently verified source review.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 3, 2026, 1:23 AM ET / 05:23 UTC.

ClawSweeper review

What this changes

The PR changes the bundled xAI plugin’s shared Responses parser to concatenate ordered text blocks and retain unique URL citations, with regression coverage at the shared parser and code-execution HTTP boundary.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 3 items remain

This PR remains necessary: current main stops at the first non-empty xAI output_text block, so later answer text and its annotations are silently omitted. The branch consolidates the repair in the shared Responses parser used by web search, X search, and code execution, and its focused tests cover the intended ordering and citation de-duplication. The patch has no concrete correctness or security finding, but the supplied live xAI invocation does not itself show a multi-block provider response reconstructed after the fix; under the external-PR proof gate, that remains a merge blocker.

Priority: P1
Reviewed head: 1f3a087f78bb023ea72c07be96f42893d0a4e866

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The shared-owner fix and focused regression coverage are solid, while proof of the exact real-provider multi-block behavior remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The PR documents an authenticated live xAI request and successful proof workflow, but it does not visibly demonstrate a real multi-block xAI response becoming the complete text and citation list after the fix; fixtures are supplemental evidence only. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The PR documents an authenticated live xAI request and successful proof workflow, but it does not visibly demonstrate a real multi-block xAI response becoming the complete text and citation list after the fix; fixtures are supplemental evidence only. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Current-main defect: The current parser returns immediately on the first non-empty nested or top-level output_text block, so subsequent blocks and their annotations cannot reach any caller.
Shared owner and sibling coverage: Web search, X search, and code execution all route response JSON through the shared helper; code execution calls it after reading the actual HTTP Response object, so the change repairs the canonical owner rather than adding a tool-specific workaround.
Proposed canonical repair: The PR accumulates every ordered message/top-level output-text block, then applies the existing unique-string normalization to collected annotation URLs while preserving the established top-level-citations preference.
Findings None None.
Security None None.

How this fits together

The bundled xAI plugin sends web-search, X-search, and code-execution requests to xAI’s Responses API. Each tool passes the returned JSON through one shared parser before handing text and citations to OpenClaw’s tool result.

flowchart LR
  A[xAI Responses API] --> B[Response JSON]
  B --> C[Shared xAI response parser]
  C --> D[Complete text and citations]
  D --> E[Web search tool]
  D --> F[X search tool]
  D --> G[Code execution tool]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The PR documents an authenticated live xAI request and successful proof workflow, but it does not visibly demonstrate a real multi-block xAI response becoming the complete text and citation list after the fix; fixtures are supplemental evidence only. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The focused fixtures prove the parser’s deterministic behavior, but merging without a redacted non-mocked multi-block xAI response leaves the original provider-shaped failure unobserved in a real setup.
  • Complete next step (P2) - The protected maintainer label and the remaining real-behavior-proof gate require human review after the contributor supplies non-mocked provider evidence; there is no mechanical code repair to dispatch.
Agent review details

Security

None.

PR surface

Source -1, Tests +97. Total +96 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 20 21 -1
Tests 2 97 0 +97
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 117 21 +96

Review metrics

Metric Value Why it matters
Production vs. test delta production -1, tests +97 The repair centralizes existing parsing behavior with a net-reduced production delta while adding coverage for the shared owner and one public tool boundary.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the shared-parser repair, then attach redacted evidence from a real xAI response containing multiple output-text blocks that visibly shows the full reconstructed text and ordered citation result after the fix.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the shared-parser repair, then attach redacted evidence from a real xAI response containing multiple output-text blocks that visibly shows the full reconstructed text and ordered citation result after the fix.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: a response whose first output_text is followed by later text blocks reproduces the omission because current main returns at the first non-empty block. The submitted fixtures encode that current failure shape, although this read-only review did not execute them.

Is this the best way to solve the issue?

Yes: repairing the shared xAI Responses parser is the narrowest maintainable solution because all three affected tools consume that owner, and the branch avoids parallel per-tool parsing logic.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d2c78e189b12.

Labels

Label justifications:

  • P1: Current xAI search and code-execution results can silently omit later provider response text and source annotations.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR documents an authenticated live xAI request and successful proof workflow, but it does not visibly demonstrate a real multi-block xAI response becoming the complete text and citation list after the fix; fixtures are supplemental evidence only. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current-main defect: The current parser returns immediately on the first non-empty nested or top-level output_text block, so subsequent blocks and their annotations cannot reach any caller. (extensions/xai/src/responses-tool-shared.ts:64, 05100271568b)
  • Shared owner and sibling coverage: Web search, X search, and code execution all route response JSON through the shared helper; code execution calls it after reading the actual HTTP Response object, so the change repairs the canonical owner rather than adding a tool-specific workaround. (extensions/xai/src/code-execution-shared.ts:92, 05100271568b)
  • Proposed canonical repair: The PR accumulates every ordered message/top-level output-text block, then applies the existing unique-string normalization to collected annotation URLs while preserving the established top-level-citations preference. (extensions/xai/src/responses-tool-shared.ts:51, 1f3a087f78bb)
  • Regression coverage: The branch adds a shared-parser fixture interleaving message and top-level output text, plus a code-execution boundary fixture with a code-interpreter call, multiple answer blocks, and duplicate citations. (extensions/xai/code-execution.test.ts:168, 1f3a087f78bb)
  • History and likely ownership: Blame attributes the current helper implementation to Peter Steinberger’s current-main commit; the PR is authored by the same established area contributor. Local history is shallow for this path, so broader feature provenance is limited. (extensions/xai/src/responses-tool-shared.ts:50, c33e9ba05b3e)
  • Proof gate status: The PR body documents one authenticated xAI invocation and the provided checks show successful real-behavior-proof runs, but the visible evidence does not show an actual multi-block xAI response and its reconstructed post-fix result. The deterministic HTTP fixtures establish the invariant but remain supplemental mocked-provider evidence. (1f3a087f78bb)

Likely related people:

  • steipete: Current-main blame attributes the shared response parser to Peter Steinberger, and this PR continues work in that same xAI response-owner surface. (role: recent response-owner contributor; confidence: medium; commits: c33e9ba05b3e, 1f3a087f78bb; files: extensions/xai/src/responses-tool-shared.ts, extensions/xai/src/code-execution-shared.ts)

Rank-up moves

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

  • Attach a redacted real xAI response or live-output artifact containing multiple output-text blocks and the resulting complete text/citation output after the fix.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-03T04:58:20.394Z sha 1f3a087 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-03T05:09:12.673Z sha 1f3a087 :: needs real behavior proof before merge. :: none

@steipete
steipete marked this pull request as ready for review August 3, 2026 05:03
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 3, 2026
@steipete
steipete merged commit 8a5cfa4 into main Aug 3, 2026
208 of 220 checks passed
@steipete
steipete deleted the codex/qa0803-xai-response-blocks branch August 3, 2026 05:34
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 3, 2026
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 P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant