| | | 1 | | using Microsoft.Extensions.AI; |
| | | 2 | | |
| | | 3 | | namespace NexusLabs.Needlr.AgentFramework; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Provides context to an <see cref="IWorkflowTerminationCondition"/> when evaluating whether a |
| | | 7 | | /// workflow should stop after an agent's response. |
| | | 8 | | /// </summary> |
| | | 9 | | public sealed class TerminationContext |
| | | 10 | | { |
| | | 11 | | /// <summary>Gets the executor ID of the agent that produced this response.</summary> |
| | 126 | 12 | | public required string AgentId { get; init; } |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Gets the last <see cref="ChatMessage"/> emitted by the agent for this turn |
| | | 16 | | /// (preserving full content including function calls, role, and metadata), or |
| | | 17 | | /// <see langword="null"/> if the agent produced no message. Use the <c>.Text</c> |
| | | 18 | | /// property on the message for a flat text view. |
| | | 19 | | /// </summary> |
| | 102 | 20 | | public ChatMessage? LastMessage { get; init; } |
| | | 21 | | |
| | | 22 | | /// <summary>Gets the number of agent turns completed so far (1-based).</summary> |
| | 69 | 23 | | public required int TurnCount { get; init; } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Gets the accumulated conversation history up to and including this turn. |
| | | 27 | | /// Each entry corresponds to one completed agent response. |
| | | 28 | | /// </summary> |
| | 69 | 29 | | public required IReadOnlyList<ChatMessage> ConversationHistory { get; init; } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Gets token usage for this turn, if reported by the model. May be <see langword="null"/> |
| | | 33 | | /// when the model does not return usage metadata. |
| | | 34 | | /// </summary> |
| | 4 | 35 | | public UsageDetails? Usage { get; init; } |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Gets the names of tools/functions called by the agent during this turn. |
| | | 39 | | /// Extracted from <see cref="FunctionCallContent"/> entries in the last message's |
| | | 40 | | /// <see cref="ChatMessage.Contents"/>. Empty if no tool calls were made. |
| | | 41 | | /// </summary> |
| | 109 | 42 | | public IReadOnlyList<string> ToolCallNames { get; init; } = []; |
| | | 43 | | } |