Table of Contents

Class AgentStreamResult

Namespace
LMKit.Agents.Streaming
Assembly
LM-Kit.NET.dll

Accumulates streaming tokens and provides the final result.

This class is both an IAgentStreamHandler that collects tokens and provides access to the accumulated content and final result.

public sealed class AgentStreamResult : IAgentStreamHandler
Inheritance
AgentStreamResult
Implements
Inherited Members

Examples

var result = new AgentStreamResult();
await foreach (var token in agent.StreamAsync("Hello", result))
{
    Console.Write(token.Text);
}

// Access final result
Console.WriteLine($"\n\nFinal: {result.Content}");
Console.WriteLine($"Status: {result.ExecutionResult?.Status}");

Properties

Agent

Gets the agent that was executed.

Content

Gets the accumulated content text.

ContentTokenCount

Gets the number of content tokens received.

Duration

Gets the duration of the streaming operation.

Error

Gets any error that occurred during streaming.

ExecutionResult

Gets the final execution result, if available.

Input

Gets the input that was provided.

IsComplete

Gets a value indicating whether streaming has completed.

IsSuccess

Gets a value indicating whether streaming completed successfully.

Thinking

Gets the accumulated thinking/reasoning text.

TokenCount

Gets the total number of tokens received.

Tokens

Gets all received tokens.

ToolCalls

Gets information about tool calls made during streaming.

Methods

OnCompleteAsync(AgentExecutionResult, CancellationToken)

Called when streaming completes.

OnErrorAsync(Exception, CancellationToken)

Called when an error occurs during streaming.

OnStartAsync(Agent, string, CancellationToken)

Called when streaming starts.

OnTokenAsync(AgentStreamToken, CancellationToken)

Called when a new token is received.

Reset()

Resets the result for reuse.

WaitForCompletionAsync(TimeSpan, CancellationToken)

Waits for streaming to complete.

Events

TokenReceived

Fired when a new token is received.