Skip to content

Backport: fix(cerebras): serialize reasoning parts as 'reasoning' on assistant messages#15425

Merged
aayush-kapoor merged 1 commit into
release-v6.0from
backport-pr-15416-to-release-v6.0
May 19, 2026
Merged

Backport: fix(cerebras): serialize reasoning parts as 'reasoning' on assistant messages#15425
aayush-kapoor merged 1 commit into
release-v6.0from
backport-pr-15416-to-release-v6.0

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

This is an automated backport of #15416 to the release-v6.0 branch. FYI @aayush-kapoor

…messages (#15416)

## Background

#15042

alternate solution to #15383

`@ai-sdk/openai-compatible` serializes the assistant reasoning as
`reasoning_content` but cerebras's chat-completions API doesnt accept
`reasoning_content` on input. their assistant-message schema uses a
`reasoning` field instead

## Summary

made the change specific to cerebras so that assistant message reasoning
parts are branded as `reasoning` instead of `reasoning_content`

## Manual Verification

verified by running the following repro: 
```ts
import { isStepCount, tool, streamText } from "ai";
import z from "zod";
import { cerebras } from "@ai-sdk/cerebras";
import { run } from '../../lib/run';

run(async () => {
  const result = streamText({
  model: cerebras('zai-glm-4.7'),
  tools: {
    create_thing: tool({
      inputSchema: z.object({ name: z.string() }),
      execute: async ({ name }) => ({ id: 'abc', name }),
    }),
  },
  stopWhen: isStepCount(5),
  messages: [{ role: 'user', content: 'create a thing called foo, then say done' }],
});

  for await (const _ of result.fullStream) {}
  console.log('steps:', (await result.steps).length);
});
```

it will fail after the first step before the fix

## Checklist

- [x] All commits are signed (PRs with unsigned commits cannot be
merged)
- [x] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)

## Future Work

look into the error seen in #15349

## Related Issues

fixes #15402
@github-actions github-actions Bot enabled auto-merge (squash) May 19, 2026 03:18
auto-merge was automatically disabled May 19, 2026 03:19

Pull request was closed

@aayush-kapoor aayush-kapoor reopened this May 19, 2026
@aayush-kapoor aayush-kapoor enabled auto-merge (squash) May 19, 2026 03:21
@aayush-kapoor aayush-kapoor merged commit 96a365b into release-v6.0 May 19, 2026
17 checks passed
@aayush-kapoor aayush-kapoor deleted the backport-pr-15416-to-release-v6.0 branch May 19, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants