fix: model narration included in history and between tool calls to prevent repetition
CI / All (ubuntu-latest) (push) Failing after 25s
CI / All (macos-latest) (push) Has been cancelled
CI / All (windows-latest) (push) Has been cancelled

This commit is contained in:
2026-07-17 16:57:51 -06:00
parent b908fc20ba
commit 078e6e3744
6 changed files with 95 additions and 40 deletions
+11 -4
View File
@@ -372,8 +372,15 @@ pub fn gemini_build_chat_completions_body(
.collect();
vec![json!({ "role": role, "parts": parts })]
},
MessageContent::ToolCalls(MessageContentToolCalls { tool_results, .. }) => {
let model_parts: Vec<Value> = tool_results.iter().map(|tool_result| {
MessageContent::ToolCalls(MessageContentToolCalls { tool_results, text, .. }) => {
let mut model_parts: Vec<Value> = vec![];
if !text.is_empty() {
model_parts.push(json!({ "text": text }));
}
for tool_result in tool_results.iter() {
if let Some(round_text) = &tool_result.text {
model_parts.push(json!({ "text": round_text }));
}
let mut part = json!({
"functionCall": {
"name": tool_result.call.name,
@@ -383,8 +390,8 @@ pub fn gemini_build_chat_completions_body(
if let Some(sig) = &tool_result.call.thought_signature {
part["thoughtSignature"] = json!(sig);
}
part
}).collect();
model_parts.push(part);
}
let function_parts: Vec<Value> = tool_results.into_iter().map(|tool_result| {
json!({
"functionResponse": {