| | | 1 | | using Microsoft.Extensions.AI; |
| | | 2 | | |
| | | 3 | | using NexusLabs.Needlr.AgentFramework.Diagnostics; |
| | | 4 | | |
| | | 5 | | namespace NexusLabs.Needlr.AgentFramework.Iterative; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Captures what happened during a single iteration of an <see cref="IIterativeAgentLoop"/>, |
| | | 9 | | /// including tool calls made, any text response produced, token usage, and wall-clock duration. |
| | | 10 | | /// </summary> |
| | | 11 | | /// <param name="Iteration">Zero-based iteration index.</param> |
| | | 12 | | /// <param name="ToolCalls"> |
| | | 13 | | /// All tool calls executed during this iteration, in execution order. |
| | | 14 | | /// Empty if the model produced a text response without requesting tools. |
| | | 15 | | /// </param> |
| | | 16 | | /// <param name="FinalResponse"> |
| | | 17 | | /// The final <see cref="ChatResponse"/> produced by the model during this iteration |
| | | 18 | | /// (preserving full message content, role, usage, and metadata), or |
| | | 19 | | /// <see langword="null"/> if the model only made tool calls without a terminating |
| | | 20 | | /// text response. In <see cref="ToolResultMode.OneRoundTrip"/> and |
| | | 21 | | /// <see cref="ToolResultMode.MultiRound"/> modes, this is the response emitted after |
| | | 22 | | /// tool results were sent back. Call <c>.Text</c> for a flat text view when evaluating. |
| | | 23 | | /// </param> |
| | | 24 | | /// <param name="Tokens">Aggregate token usage across all LLM calls in this iteration.</param> |
| | | 25 | | /// <param name="Duration">Wall-clock time for the entire iteration (LLM calls + tool execution).</param> |
| | | 26 | | /// <param name="LlmCallCount"> |
| | | 27 | | /// Number of LLM calls made during this iteration. Always 1 for |
| | | 28 | | /// <see cref="ToolResultMode.SingleCall"/>, at most 2 for |
| | | 29 | | /// <see cref="ToolResultMode.OneRoundTrip"/>. |
| | | 30 | | /// </param> |
| | | 31 | | /// <param name="ToolCallCount"> |
| | | 32 | | /// Number of tool calls executed during this iteration. |
| | | 33 | | /// </param> |
| | 262 | 34 | | public sealed record IterationRecord( |
| | 14 | 35 | | int Iteration, |
| | 45 | 36 | | IReadOnlyList<ToolCallResult> ToolCalls, |
| | 59 | 37 | | ChatResponse? FinalResponse, |
| | 42 | 38 | | TokenUsage Tokens, |
| | 1 | 39 | | TimeSpan Duration, |
| | 7 | 40 | | int LlmCallCount, |
| | 266 | 41 | | int ToolCallCount); |