Skip to content

fix(xai): support encrypted reasoning round-trip for ZDR - #14418

Merged
aayush-kapoor merged 4 commits into
vercel:mainfrom
BrianHung:brian/xai-encrypted-reasoning-zdr
Apr 15, 2026
Merged

aayush-kapoor merged 4 commits into
vercel:mainfrom
BrianHung:brian/xai-encrypted-reasoning-zdr

Conversation

@BrianHung

@BrianHung BrianHung commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

On ZDR (Zero Data Retention) accounts, the xAI responses API returns reasoning with encrypted_content but empty summaries. Two bugs prevented multi-turn conversations from working:

  1. doGenerate silently dropped reasoning parts when the summary text was empty, losing the encrypted_content needed for subsequent turns.
  2. The input converter skipped all reasoning parts from assistant messages, so encrypted content could never be sent back to the API.

Also passes actual store value to the input converter instead of hardcoded true.

Manual Verification

tested by running the example http://localhost:3000/chat/xai-web-search with a ZDR enabled key

@tigent tigent Bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/xai Issues related to the @ai-sdk/xai provider labels Apr 14, 2026
On ZDR (Zero Data Retention) accounts, the xAI responses API returns
reasoning with encrypted_content but empty summaries. Two bugs prevented
multi-turn conversations from working:

1. doGenerate silently dropped reasoning parts when the summary text was
   empty, losing the encrypted_content needed for subsequent turns.

2. The input converter skipped all reasoning parts from assistant messages,
   so encrypted content could never be sent back to the API.

Also passes actual store value to input converter instead of hardcoded true.
@BrianHung
BrianHung force-pushed the brian/xai-encrypted-reasoning-zdr branch from c76a3c5 to 9843f90 Compare April 14, 2026 02:03
@BrianHung
BrianHung marked this pull request as ready for review April 14, 2026 02:03

@aayush-kapoor aayush-kapoor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll make these changes

@aayush-kapoor aayush-kapoor added the backport Admins only: add this label to a pull request in order to backport it to the prior version label Apr 15, 2026
@aayush-kapoor
aayush-kapoor merged commit 8d87577 into vercel:main Apr 15, 2026
20 of 21 checks passed
ghost pushed a commit that referenced this pull request Apr 15, 2026
@ghost ghost removed the backport Admins only: add this label to a pull request in order to backport it to the prior version label Apr 15, 2026
@ghost

ghost commented Apr 15, 2026

Copy link
Copy Markdown

⚠️ Backport to release-v6.0 created but has conflicts: #14497

@ghost

ghost commented Apr 15, 2026

Copy link
Copy Markdown

🚀 Published in:

Package Version
@ai-sdk/xai 4.0.0-beta.37

aayush-kapoor added a commit that referenced this pull request Apr 15, 2026
…14497)

This is an automated backport of #14418 to the release-v6.0 branch. FYI
@BrianHung
This backport has conflicts that need to be resolved manually.

### `git cherry-pick` output

```
Auto-merging packages/xai/src/responses/convert-to-xai-responses-input.ts
CONFLICT (content): Merge conflict in packages/xai/src/responses/convert-to-xai-responses-input.ts
Auto-merging packages/xai/src/responses/xai-responses-language-model.test.ts
CONFLICT (content): Merge conflict in packages/xai/src/responses/xai-responses-language-model.test.ts
Auto-merging packages/xai/src/responses/xai-responses-language-model.ts
CONFLICT (content): Merge conflict in packages/xai/src/responses/xai-responses-language-model.ts
Auto-merging packages/xai/src/responses/xai-responses-options.ts
error: could not apply 8d87577... fix(xai): support encrypted reasoning round-trip for ZDR (#14418)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
```

---------

Co-authored-by: Brian Hung <[email protected]>
Co-authored-by: Aayush Kapoor <[email protected]>
gr2m pushed a commit that referenced this pull request Jun 5, 2026
On ZDR (Zero Data Retention) accounts, the xAI responses API returns
reasoning with `encrypted_content` but empty summaries. Two bugs
prevented multi-turn conversations from working:

1. `doGenerate` silently dropped reasoning parts when the summary text
was empty, losing the `encrypted_content` needed for subsequent turns.
2. The input converter skipped all reasoning parts from assistant
messages, so encrypted content could never be sent back to the API.

Also passes actual `store` value to the input converter instead of
hardcoded `true`.

## Manual Verification

tested by running the example
`http://localhost:3000/chat/xai-web-search` with a ZDR enabled key

---------

Co-authored-by: Aayush Kapoor <[email protected]>
Co-authored-by: Aayush Kapoor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/xai Issues related to the @ai-sdk/xai provider task-merge-tracking-no-issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants