Skip to content

Conversation

@Tarquinen
Copy link
Collaborator

Summary

  • Switch prunable-tools context injection from user message to assistant message role
  • Remove redundant instruction block that was no longer needed with the new approach

… message

Instead of creating a synthetic assistant message (which breaks thinking
models that require the final assistant message to start with a thinking
block), inject the prunable tools list as a text part appended to the
most recent assistant message. This preserves the message structure
during tool use loops and works across all providers/models.
@zackleman
Copy link

Did this yield better results for you?

@Tarquinen
Copy link
Collaborator Author

Tarquinen commented Dec 20, 2025

Yes the performance is definitely better, models are trained to address user messages so getting them to ignore the message is very hacky, but its harder to work with for 2 reasons:

  1. Assistant messages can't be injected wherever you want the way user messages can, for example anthropic models require all assistant blocks to either have thinking or not have thinking depending on if its enabled or not.
  2. Can get around number 1 by injecting into the last existing assistant message, but this leads to weird UI bugs in opencode and only sometimes with some providers, not sure why or if there's a way around it. Looks like this:

image

I haven't looked into this too much yet, if anyone wants to help this would be big!

@Tarquinen
Copy link
Collaborator Author

figured this out finally, merged to dev in #187

@Tarquinen Tarquinen closed this Dec 23, 2025
@Tarquinen Tarquinen deleted the refactor/synthetic-context-to-assistant-role branch January 6, 2026 19:05
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.

3 participants