ProcessChatClient<T>
Models & Types · AiDotNet.Agentic.Models.Connectors
An IChatClient that reaches a model by running a command-line program.
Implements: IChatClient<T>
For Beginners
Use this when your model is a program you run rather than a web service. Give it the command and, if the program supports one, a spending cap per call.
How It Works
Not every model is an HTTP endpoint. A locally installed agent, a vendor’s own CLI, or a wrapper script that holds credentials this process should never see are all reached by running a command, and this is the client for that shape. The conversation is written to the program’s standard input and its standard output is the reply.
Three things make that safe enough to run thousands of times in an evolution run. The prompt goes on standard
input rather than in an argument, so a long conversation cannot overflow the operating system’s command-length
limit or end up in a process listing. Every call is bounded by a timeout and the process is killed, with its
children, when it expires, so one hung model does not stall a run. And
MaxBudgetUsd is passed to the program on every call, because a subprocess
model can be an agent that decides for itself how much work a prompt deserves.
A non-zero exit code becomes an exception carrying the exit code and a bounded excerpt of standard error, which is what a caller needs to tell “the command is missing” from “the model refused”.
Constructors
| Constructor | Summary |
|---|---|
ProcessChatClient(ProcessChatClientOptions options) |
Initializes a client over a command. |
ProcessChatClient(string fileName, ProcessChatClientOptions options) |
Initializes a client over a command named directly, with everything else left at its default. |
Properties
| Property | Summary |
|---|---|
IReadOnlyList<string> Arguments { get; } |
Gets the arguments passed on every call, budget included. |
long Calls { get; } |
Gets how many times the command has been run. |
string ModelId { get; } |
Methods
| Method | Summary |
|---|---|
IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IReadOnlyList<ChatMessage> messages, ChatOptions options, CancellationToken cancellationToken) |
|
Task<ChatResponse> GetResponseAsync(IReadOnlyList<ChatMessage> messages, ChatOptions options, CancellationToken cancellationToken) |