[PR #4873] fix: take snapshot before stream starts to fix diff tracking for some providers #11147

Closed
opened 2026-02-16 18:15:56 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/4873

State: closed
Merged: No


Summary

  • Fix empty "Modified Files" sidebar when using certain LLM providers (e.g., GLM-4.6 via models.dev)

Problem

The start-step event from the AI SDK fires at different times depending on the provider:

  • Anthropic: fires before tool execution → correct "before" snapshot
  • Some providers (GLM-4.6, etc.): fires after tool execution has begun → snapshot captures "after" state
    This caused step-start and step-finish snapshots to have identical hashes, resulting in empty diffs in the Modified Files sidebar.

Solution

Take the snapshot before the stream starts instead of waiting for the start-step event. This ensures we always capture the true "before" state regardless of provider timing.

Testing

Tested with:

  • GLM-4.6 via models.dev (zai-coding-plan) - previously broken, now working
  • Anthropic Haiku 4.5 - still working correctly

Before the change, 'Modified Files' was not present:

image

After the change updates to the file were tracked well coming from GLM and Haiku

image
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/4873 **State:** closed **Merged:** No --- ## Summary - Fix empty "Modified Files" sidebar when using certain LLM providers (e.g., GLM-4.6 via models.dev) ## Problem The `start-step` event from the AI SDK fires at different times depending on the provider: - **Anthropic**: fires before tool execution → correct "before" snapshot - **Some providers (GLM-4.6, etc.)**: fires after tool execution has begun → snapshot captures "after" state This caused `step-start` and `step-finish` snapshots to have identical hashes, resulting in empty diffs in the Modified Files sidebar. ## Solution Take the snapshot **before** the stream starts instead of waiting for the `start-step` event. This ensures we always capture the true "before" state regardless of provider timing. ## Testing Tested with: - GLM-4.6 via models.dev (zai-coding-plan) - previously broken, now working - Anthropic Haiku 4.5 - still working correctly Before the change, 'Modified Files' was not present: <img width="1469" height="678" alt="image" src="https://github.com/user-attachments/assets/6ca6078d-dc50-402a-92a0-e85a48b9bd8c" /> After the change updates to the file were tracked well coming from GLM and Haiku <img width="1136" height="1368" alt="image" src="https://github.com/user-attachments/assets/31ab1e38-8380-41b1-b4a9-e190736b5536" />
yindo added the pull-request label 2026-02-16 18:15:56 -05:00
yindo closed this issue 2026-02-16 18:15:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11147