Repository navigation
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Some models (e.g., zhipu/glm) emit a separate reasoning-start/delta/end cycle for every single token, causing each token to render as an independent 'Thinking:' line in the TUI. Fix by tracking the last reasoning part and reusing it when consecutive reasoning-start events arrive, instead of creating a new part each time. The merged part is finalized at text-start or finish-step. Also normalize newlines in ReasoningPart render as defense-in-depth.
3fc1adc to
75b8316
Compare
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #22241
Type of change
What does this PR do?
Some models (e.g., zhipu/glm) emit a separate
reasoning-start→reasoning-delta→reasoning-endcycle for every single token during reasoning/thinking output. This causes each token to create an independent reasoningPartwith a uniquepartID, resulting in the TUI rendering each token as a separateThinking:line:Root cause: The AI SDK adapter for these models wraps each token in its own reasoning lifecycle event, unlike models such as DeepSeek which emit one
reasoning-start, manyreasoning-deltas, and onereasoning-end.Fix in
processor.ts: Track the last reasoning part via_lastReasoningEntry. When a newreasoning-startarrives and a previous reasoning part exists, reuse it instead of creating a new one.reasoning-endno longer finalizes the part — it just cleans up the map entry. The merged part is finalized whentext-startorfinish-stepfires (viafinalizeReasoning()).Defense-in-depth in
index.tsx: Normalize newlines inReasoningPart'screateMemo— collapse single\n(token boundaries) to spaces while preserving\n\n(paragraph breaks).How did you verify your code works?
zhipu/glm-5via Mify gateway — thinking content now renders as a continuous paragraphpartIDScreenshots / recordings
N/A — terminal behavior fix, not UI change.
Checklist