Skip to content

Interrupted thinking-only message causes 400 error (patch part bypasses filter) #9042

Closed

Description

@grumpygordon

Interrupting (Esc) while assistant is in thinking mode (reasoning only, no text output yet) breaks the session.

Next request fails with:

messages.X: all messages must have non-empty content except for the optional final assistant message

Related to #3101 but different root cause.

Repro:

  1. Use thinking model (claude-opus with high variant)
  2. Interrupt while "Thinking:" is displayed, before any text
  3. Send another message → 400 error

Cause:
message-v2.ts:toModelMessage() line 483:

msg.parts.some((part) => part.type !== "step-start" && part.type !== "reasoning")

Aborted messages should be skipped if they only have step-start/reasoning. But the patch part (created on abort) passes this check, so the message gets included with only reasoning content. Anthropic rejects non-final assistant messages with only reasoning.

Fix:
Add patch to exclusion, or check for output-producing parts (text, tool) explicitly.

  • macOS, dev build

Activity

  1. github-actions commented on Jan 17, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    The root cause appears to be similar: messages reaching the API with no text or output-producing content. Your specific case involves thinking-only content filtered out, while #6446 was about tool-only messages, but the underlying issue in toModelMessage() filtering logic seems related.

    Feel free to ignore if your case is indeed the specific 'patch part' bypass issue described in your report.

  2. grumpygordon commented on Jan 17, 2026

    @grumpygordon
    Author

    Sorry, created this accidentally with opencode, its my local build error...

  3. dan-cooke commented on Jan 27, 2026

    @dan-cooke

    I'm also experiencing this all the time since the most recent update - if anyone stumbles upon here, you an fix it by Cmd + P > Fork and picking your most recent message

    There is some bug with opencode that causes the context to be continuously empty, it seems to happen most frequently when you cancel an LLM output

  4. madeleineostoja commented on Feb 4, 2026

    @madeleineostoja

    Also experiencing this when interrupting thinking. Forking from a known good state is a good workaround

  5. ujjwaljainnn commented on Feb 10, 2026

    @ujjwaljainnn

    Also experiencing this when interrupting thinking. Forking from a known good state is a good workaround

    If you didn't have file changes, you can also just click on your last message and run the revert command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions