Skip to content

fix(opencode): replay Cerebras reasoning in assistant content#26763

Closed
ryanl-cerebras wants to merge 8 commits into
anomalyco:devfrom
ryanl-cerebras:codex/cerebras-reasoning-history-replay
Closed

fix(opencode): replay Cerebras reasoning in assistant content#26763
ryanl-cerebras wants to merge 8 commits into
anomalyco:devfrom
ryanl-cerebras:codex/cerebras-reasoning-history-replay

Conversation

@ryanl-cerebras

Copy link
Copy Markdown

Issue for this PR

Closes #26762

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Cerebras models go through @ai-sdk/openai-compatible, which replays assistant reasoning parts as assistant.reasoning_content.

That breaks follow-up turns for Cerebras reasoning models like cerebras/zai-glm-4.7, which expect prior reasoning to be folded back into assistant.content.

This change rewrites prior assistant reasoning parts before serialization for @ai-sdk/cerebras:

  • GLM reasoning is replayed as <think>...</think> text
  • GPT-OSS reasoning is replayed as plain assistant text

It also adds regression tests for both cases.

How did you verify your code works?

  • Reproduced the failure on opencode 1.14.41 with cerebras/zai-glm-4.7 using:
    • build an frontend for inferencex performance benchmark
  • Verified the patched local build gets past the follow-up turn that previously failed
  • Ran:
    • bun test test/provider/transform.test.ts
  • Confirmed the new Cerebras regression tests pass

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Comment thread CEREBRAS_REASONING_HISTORY_REPLAY_README.md Outdated
@map9959

map9959 commented Jun 23, 2026

Copy link
Copy Markdown

This may be addressed through the SDK version in #30186

@ryanl-cerebras

Copy link
Copy Markdown
Author

Closing as superseded by #34826, which fixes #26762 through the updated Cerebras SDK and adds request-level regression coverage. Thanks for getting this issue identified and helping validate the expected reasoning replay behavior.

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.

Cerebras zai-glm-4.7 fails on follow-up turn with reasoning_content

3 participants