Skip to content

fix: ensure last message is from user #45359 - #51104

Closed
invisibleroads wants to merge 2 commits into
anomalyco:devfrom
invisibleroads:dev
Closed

invisibleroads wants to merge 2 commits into
anomalyco:devfrom
invisibleroads:dev

Conversation

@invisibleroads

Copy link
Copy Markdown

Issue for this PR

Closes #45359

Type of change

  • Bug fix

What does this PR do?

Some models (such as Gemini) require the the last message to be a user message. This is a quick monkeypatch to ensure that the last message is a user message.

How did you verify your code works?

It's hard to tell because the error sometimes surfaces and sometimes doesn't and so isn't easy to reproduce.

{"type":"step_start"}
{"type":"reasoning"}
{"type":"step_finish","reason":"unknown"}
{"type":"error"}

It seems to happen when the model is thinking for a long time. I'm not familiar with this repository so I'm not sure of the ramifications of this change.

Will adding the user message increase token usage in non-Gemini models?

Screenshots / recordings

Checklist

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

@github-actions

Copy link
Copy Markdown
Contributor

Hey! Your PR title Fix #45359 with workaround doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@invisibleroads invisibleroads changed the title Fix #45359 with workaround fix: #45359 with workaround Sep 24, 2026
@invisibleroads invisibleroads changed the title fix: #45359 with workaround fix: ensure last message is from user #45359 Sep 24, 2026
@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

@thdxr thdxr closed this Oct 10, 2026
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.

Requests ending with a model turn are not supported

2 participants