Add per-answer thinking disclosure

This commit is contained in:
Peer Hogeterp committed 2026-09-10 15:37:43 +02:00
1 parent c7b42bee96
commit bbbcdddc91
29 files changed
+360 -37

No files matched your search

@@ -28,6 +28,7 @@ public sealed class ToolCallingLoop(ILogger<ToolCallingLoop> logger) : IToolCall
var toolCallCount = 0;
var toolResultCharacterCount = 0L;
var toolSources = new List<Source>();
var hasThinkingOutput = false;
while (true)
{
@@ -47,6 +48,13 @@ public sealed class ToolCallingLoop(ILogger<ToolCallingLoop> logger) : IToolCall
toolSources.MergeSources(round.Sources);
if (!string.IsNullOrWhiteSpace(round.ThinkingOutput))
{
var separator = hasThinkingOutput ? $"{Environment.NewLine}{Environment.NewLine}" : string.Empty;
yield return new ContentStreamChunk(string.Empty, $"{separator}{round.ThinkingOutput}", []);
hasThinkingOutput = true;
}
//
// A call without an ID cannot be answered: the provider correlates the result by that
// ID, and inventing one would have the next request rejected. Nothing can be salvaged
@@ -168,4 +176,4 @@ public sealed class ToolCallingLoop(ILogger<ToolCallingLoop> logger) : IToolCall
private static string GetDisplayName(ToolCallingLoopContext context, string toolName) => context.RunnableTools
.FirstOrDefault(tool => tool.Definition.Function.Name.Equals(toolName, StringComparison.Ordinal))
.Implementation?.GetDisplayName() ?? toolName;
}
}