[PR #8949] fix: remove invalid step-start parts from UIMessage conversion #12922

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

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

State: closed
Merged: No


Summary

Fixes AI_InvalidPromptError that breaks sessions when compaction is triggered.

Problem

When a session's context overflows and compaction is triggered, the following error occurs:

AI_InvalidPromptError: Invalid prompt: The messages must be a ModelMessage[]. 
If you have passed a UIMessage[], you can use convertToModelMessages to convert them.

This happens because step-start parts are being added to UIMessage objects, but step-start is not a valid UIMessagePart type in the AI SDK's convertToModelMessages() function.

Solution

  • Remove step-start from being added to UIMessage parts (it's only used internally for tracking)
  • Simplify the result filter since step-start is no longer included

Testing

  • Sessions can now compact without errors
  • Existing sessions with context overflow can be recovered
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8949 **State:** closed **Merged:** No --- ## Summary Fixes `AI_InvalidPromptError` that breaks sessions when compaction is triggered. ## Problem When a session's context overflows and compaction is triggered, the following error occurs: ``` AI_InvalidPromptError: Invalid prompt: The messages must be a ModelMessage[]. If you have passed a UIMessage[], you can use convertToModelMessages to convert them. ``` This happens because `step-start` parts are being added to `UIMessage` objects, but `step-start` is not a valid `UIMessagePart` type in the AI SDK's `convertToModelMessages()` function. ## Solution - Remove `step-start` from being added to UIMessage parts (it's only used internally for tracking) - Simplify the result filter since `step-start` is no longer included ## Testing - [x] Sessions can now compact without errors - [x] Existing sessions with context overflow can be recovered
yindo added the pull-request label 2026-02-16 18:17:48 -05:00
yindo closed this issue 2026-02-16 18:17:48 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12922