Improved how the AI remembers its earlier tool calls (#1185)

Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
Peer HogeterpandThorsten Sommer authored and GitHub committed 2026-11-12 19:57:28 +01:00
1 parent 0885862150
commit 382db4b8d0
22 files changed
+1323 -24

No files matched your search

+17
View File
@@ -83,6 +83,23 @@ public sealed class ConversationPartsTests
}
}
[Test]
public void AnEarlierAnswerCountsWithTheNoteOfTheToolsItUsed()
{
var answer = new ContentText
{
Text = "The page describes the travel rules.",
ToolInvocations = [new ToolInvocationTrace { Order = 1, ToolId = "read_web_page", Status = ToolInvocationTraceStatus.SUCCESS, WasExecuted = true, Arguments = new() { ["url"] = "https://example.org/travel" }, ArgumentsJson = """{"url":"https://example.org/travel"}""" }],
};
var time = new DateTimeOffset(2026, 11, 5, 14, 32, 0, TimeSpan.Zero);
var thread = new ChatThread { Blocks = [new ContentBlock { Role = ChatRole.AI, ContentType = ContentType.TEXT, Content = answer, Time = time }] };
var parts = ConversationParts.Of(thread, string.Empty, string.Empty, null, imagesAreSent: true, toolDefinitions: null);
Assert.That(parts.Texts, Is.EqualTo(new[] { $"{ToolCallHistoryNote.Build(answer, time)}\n\n{answer.Text}" }), "The message builder sends the note in front of the answer.");
}
[Test]
public void AnAnswerWhichIsFinishedStandsLikeAnyOtherMessage()
{