mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-13 14:47:21 +00:00
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:
1 parent
0885862150
commit
382db4b8d0
22 files changed
+1323
-24
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using AIStudio.Chat;
|
||||
using AIStudio.Provider;
|
||||
using AIStudio.Tools.ToolCallingSystem;
|
||||
|
||||
namespace AIStudio.Tests.Chat;
|
||||
|
||||
@@ -41,6 +42,26 @@ public sealed class ChatThreadReportedHistoryTests
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheLastAnswerCountsWithTheNoteOfTheToolsItUsed()
|
||||
{
|
||||
//
|
||||
// The provider counted the request before the answer, so the note which the answer carries
|
||||
// into the next request is part of no report yet:
|
||||
//
|
||||
var answer = new ContentText
|
||||
{
|
||||
Text = "Answer 2",
|
||||
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"}""" }],
|
||||
};
|
||||
|
||||
answer.RecordReportedUsage(TokenUsage.Of(1200), MODEL.Id, 2);
|
||||
var block = Block(ChatRole.AI, answer, 2);
|
||||
var thread = Thread(Question(1), block);
|
||||
|
||||
Assert.That(thread.ReportedHistoryFor(MODEL).LastAnswer, Is.EqualTo($"{ToolCallHistoryNote.Of(block)}\n\nAnswer 2"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AnAnswerWithoutTextAddsNothingToThePrompt()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user