Repository navigation
Send tool results as user messages when the template can't show them - #14
Merged
Merged
Conversation
OLMo-2's chat template silently drops role "tool" messages, and Mistral-7B-Instruct-v0.3's rejects them (it wants tool-call IDs and strict user/assistant alternation). Either way the model never learned whether its steer calls worked. chat.supports_tool_role() probes the template once per tokenizer. Where tool messages aren't shown, adapt_messages() sends them as user messages starting with "[Tool result]" and merges consecutive user messages. Session logs record tool_role. Checked on a GPU: OLMo-2 now sees its tool results and stacks a second vector on the first; Mistral no longer errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some chat templates can't show role
toolmessages, so the model never learns whether itssteer/drop/reportcalls worked:Changes
modulo/chat.py:supports_tool_role(tokenizer)renders a probe conversation once per tokenizer and caches the result. When tool messages aren't shown,adapt_messages()sends them as user messages starting with[Tool result]and merges consecutive user messages.chat_prompt()applies this automatically. The caller's messages are not modified.agent/loop.py: the session header recordstool_role.tests/test_chat.py: CPU tests with stub tokenizers that mimic each failure.AGENTS.md: a support table for the tested models (Qwen2.5, Llama-3.1, OLMo-2, Mistral v0.3, Gemma-2).Testing
test_chat,test_agent_logicandtest_cli).tool_roleis True for Qwen2.5 and Llama-3.1, and False for OLMo-2 and Mistral v0.3.creativity+7.5 and later addedoptimism+8.5, so it now sees its tool results.🤖 Generated with Claude Code