From 71d3d2d350fb997861ec59ceed9eabf9a91f0d82 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 25 Sep 2026 17:50:20 +0530 Subject: [PATCH 1/2] fix: keep tool result and active request in one turn --- crates/tinyinference-llm/src/prompt_tools/mod.rs | 16 +++++++++++----- .../tinyinference-llm/src/prompt_tools/test.rs | 7 +++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/crates/tinyinference-llm/src/prompt_tools/mod.rs b/crates/tinyinference-llm/src/prompt_tools/mod.rs index 358af54a..2b95d803 100644 --- a/crates/tinyinference-llm/src/prompt_tools/mod.rs +++ b/crates/tinyinference-llm/src/prompt_tools/mod.rs @@ -232,8 +232,10 @@ pub fn ensure_resolvable_user_turn(messages: &[Message]) -> Vec { /// Keep the active request at the end of a prompt-guided tool continuation. /// Some chat templates treat the synthetic tool-result user turn as transport /// data and resolve an earlier user message as the query. Repeating the latest -/// real text request after a terminal result gives those templates the correct -/// query without changing the durable transcript. +/// real text request alongside a terminal result gives those templates the +/// correct query without changing the durable transcript. Both belong in one +/// user turn: a separate trailing request makes a model restart discovery and +/// ignore the result it just received. #[must_use] pub fn anchor_user_request_after_tool_result(messages: &[Message]) -> Vec { if !messages.last().is_some_and(|message| { @@ -258,9 +260,13 @@ pub fn anchor_user_request_after_tool_result(messages: &[Message]) -> Vec Date: Fri, 25 Sep 2026 17:56:25 +0530 Subject: [PATCH 2/2] fix: preserve tool result blocks in continuation --- .../tinyinference-llm/src/prompt_tools/mod.rs | 16 +++++++++----- .../src/prompt_tools/test.rs | 21 +++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/crates/tinyinference-llm/src/prompt_tools/mod.rs b/crates/tinyinference-llm/src/prompt_tools/mod.rs index 2b95d803..08ca0542 100644 --- a/crates/tinyinference-llm/src/prompt_tools/mod.rs +++ b/crates/tinyinference-llm/src/prompt_tools/mod.rs @@ -260,12 +260,18 @@ pub fn anchor_user_request_after_tool_result(messages: &[Message]) -> Vec