Skip to content

fix(xai): preserve stateful Responses output-only continuations - #587

Open
luvs01 wants to merge 3 commits into
devfrom
codex/propose-fix-for-xai-output-handling
Open

luvs01 wants to merge 3 commits into
devfrom
codex/propose-fix-for-xai-output-handling

Conversation

@luvs01

@luvs01 luvs01 commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent a regression where enabling xAI pairing caused function_call_output/custom_tool_call_output items to be rewritten into user messages when the matching function_call still lived upstream behind previous_response_id.
  • Keep existing stateless/forward repair behavior (synthesizing missing outputs) while not breaking stateful xAI continuations that the upstream can resolve.

Description

  • Add a conditional repair control to repairOrphanedInputItems by introducing a repairOrphanOutputs parameter so orphan-output-to-user-message conversion can be toggled, and preserve the original signature-compatible behavior when enabled (src/adapters/openai-responses/tool-output-recovery.ts).
  • Compute a destination-aware decision in the Responses passthrough so stateful xAI continuations are preserved: call repairOrphanedInputItems with repairOrphanOutputs enabled only when appropriate (forward or stateless wires, or when there is no unexpanded previous_response_id) (src/adapters/openai-responses/passthrough.ts).
  • Add regression tests that assert output-only continuations are preserved when the call is expected to be resolved upstream and that standalone orphan outputs are still repaired into user messages (tests/providers/xai/xai-responses-adjacency.test.ts).
  • Update the compatibility documentation to clarify the distinction between adjacency and pairing and to document that pairing synthesizes placeholders only for calls present in the current input while preserving output-only continuations that rely on server-side state (structure/providers/chat-compat.md).

Testing

  • Ran the focused xAI suite: bun test tests/providers/xai/xai-responses-adjacency.test.ts and related focused dangling-call suites; the focused set passed (8–25 tests depending on scope) on the repo Bun (node_modules/bun/bin/bun.exe v1.4.0).
  • Ran typecheck with bun x tsc --noEmit and structure SSOT checks with bun run structure:check; both succeeded.
  • Ran the focused trio: tests/providers/xai/xai-responses-adjacency.test.ts, tests/responses/responses-forward-dangling-call.test.ts, and tests/responses/responses-stateless-dangling-call-repair.test.ts; these passed end-to-end in the environment used.
  • Note: a full-repo bun run test in this container showed unrelated environment/timing/process-group flakes in other suites; the changes in this PR are covered by the focused tests which passed.

Codex Task


Devin Review

devin-ai-integration Bot and others added 2 commits September 20, 2026 13:22
…forwarded role (lidge-jun#5334 follow-up)

lidge-jun#5334 made the developer wire role tri-state: an undeclared destination folds
it to system. Two suites asserting role:"developer" on the Chat wire were
missed because they are about tool-result repair ordering and document parts,
not role selection — declare the destination, per the convention the change
established.

Verified: both files fail on dev@600075d2 with system-for-developer wire roles
and pass with the declaration.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: luvs01/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 0d0ff214-43fb-42a1-85d9-3009fa1b3f52


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Sep 21, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-21T00:46:36.184027Z 4edc411 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…pair

Co-Authored-By: Epinephrine <luvs01@hanmail.net>
@devin-ai-integration

Copy link
Copy Markdown

Fixed in 67ccd8ddropReasoning now takes unexpandedMiss directly, restoring the replay-miss reasoning cleanup for stateful paired destinations; repairOrphanOutputs remains the independent fourth argument gating only orphan-output conversion.

1 similar comment
@devin-ai-integration

Copy link
Copy Markdown

Fixed in 67ccd8ddropReasoning now takes unexpandedMiss directly, restoring the replay-miss reasoning cleanup for stateful paired destinations; repairOrphanOutputs remains the independent fourth argument gating only orphan-output conversion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant