Corfedo.Extensions.AI
0.0.2
Prefix Reserved
dotnet add package Corfedo.Extensions.AI --version 0.0.2
NuGet\Install-Package Corfedo.Extensions.AI -Version 0.0.2
<PackageReference Include="Corfedo.Extensions.AI" Version="0.0.2" />
<PackageVersion Include="Corfedo.Extensions.AI" Version="0.0.2" />
<PackageReference Include="Corfedo.Extensions.AI" />
paket add Corfedo.Extensions.AI --version 0.0.2
#r "nuget: Corfedo.Extensions.AI, 0.0.2"
#:package Corfedo.Extensions.AI@0.0.2
#addin nuget:?package=Corfedo.Extensions.AI&version=0.0.2
#tool nuget:?package=Corfedo.Extensions.AI&version=0.0.2
Corfedo.Extensions.AI
.NET 10 read-only Corfedo functions for a consumer's existing models and agents.
Apache-2.0. Depends only on Corfedo.Client and
Microsoft.Extensions.AI.Abstractions (plus their transitive dependencies).
using Corfedo.Extensions.AI;
using Microsoft.Extensions.AI;
// corfedo is an already opened, consumer-owned CorfedoClient.
// existingModel is the consumer's IChatClient.
var tools = corfedo.GetAITools();
using var chat = existingModel.AsBuilder().UseFunctionInvocation().Build();
var response = await chat.GetResponseAsync("Find the search implementation",
new ChatOptions { Tools = [.. tools] }, cancellationToken);
Invocation middleware comes from the consumer's Microsoft.Extensions.AI package.
Tool creation performs no network/authentication calls and installs no middleware.
The consumer owns credentials, client/model lifetime, and the invocation loop.
Use exactly one loop; ChatClientAgent supplies its own.
var tools = corfedo.GetAITools(new()
{
Groups = CorfedoAIToolGroups.Search | CorfedoAIToolGroups.Code,
MaximumResultBytes = 512 * 1024
});
// Groups and individual names are unioned. None selects only the named tools.
var search = corfedo.GetAITools(new()
{
Groups = CorfedoAIToolGroups.None,
Tools = ["search_code", "read_file"]
});
Default groups are Search, Code and Catalog (9 tools). search_code takes one
query syntax: words, such as a behavior description or identifiers, are ranked by
relevance; "…" is an exact phrase and /…/ a regular expression; uppercase AND,
OR and NOT combine them; filters such as repo:, file:, lang: and sym:
narrow the search, for example "retry" OR /backoff\w*/ lang:csharp.
CorfedoAITools.Instructions is optional text for the agent's system prompt: it
explains that a run of * in a credential is masked by the index.
Diagnostics/connection_info is opt-in. Status-only read_context is omitted.
All invocations go through the public SDK with its fixed authenticated connection.
There is no backend tool proxy, MCP transport, or platform assembly dependency.
The upstream AIFunctionFactory owns schemas, argument binding, cancellation
binding and JSON marshaling. Source-generated JSON metadata supports NativeAOT
without reflection JSON. A small decorator translates safe SDK failures into
CorfedoAIToolException; its Code, CorrelationId and RetryAfter remain available.
Result-size enforcement checks the upstream serialized result. Oversize results
fail with narrowing guidance, without delivering a shortened page or skipping cursor.
Arguments, defaults, descriptions and results follow the platform MCP tools.
read_chunks exists only here. Results use compact camelCase JSON: status is always
present; optional null/false and empty collections are omitted. Integer quantities
are serialized directly as integers, without conversion to floating point. Line
ranges are 1-based inclusive; read_chunks spans and chunk bytes are half-open
UTF-8 offsets. Code is addressed by repo (canonical github.com/owner/name or a
unique owner/name) and path or dir; search and symbol results carry
repo, path and revision, usable directly by read_file, list_tree and
list_file_symbols. The functions take no revision and read the
repository's serving build; every result reports the commit read as revision.
A listing continued after its build is no longer retained answers stale with
currentRevision; restart it. Partial, unavailable, scope reduction, truncation and
continuation remain distinct. Fetches are bounded to one page; repeat identical
arguments with next.
CorfedoChatClient
CorfedoChatClient makes Corfedo's agent an IChatClient. It is stateful: the
conversation lives in Corfedo, which keeps the history, runs its own read tools and
owns the profile's model and settings. The client needs the corfedo:ai:invoke scope.
using var chat = new CorfedoChatClient(corfedo).AsBuilder().UseFunctionInvocation().Build();
var first = await chat.GetResponseAsync("How does shard selection work?");
var next = await chat.GetResponseAsync("And how are shards loaded?", new() { ConversationId = first.ConversationId });
Capabilities:
A call sends one new user message (text), or the results of the client tool calls of a pending turn.
ChatOptions.ConversationIdnames the conversation; without it a call starts one, and the response carries its ID.ChatClientAgentsessions keep it.The profile an administrator set for API access (Settings › Client access) answers, and a response names it as
ModelId.ChatOptions.ModelIdis rejected.ChatOptions.Toolsfunctions are client tools the caller runs: the response ends withFunctionCallContentandFinishReason.ToolCalls, and the next call carries onlyFunctionResultContentwith the conversation ID, asUseFunctionInvocationsends it. Corfedo's own tool calls are informationalFunctionCallContent.ChatOptions.ResponseFormatwith a JSON schema makes the answer that JSON value. A streaming call then yields the validated answer once, after the run completes.Sources, references, limits and core tool narrowing come from
CorfedoChatOptionsreturned byChatOptions.RawRepresentationFactory. They apply to a call that sends a user message; a tool-result call continues a run whose inputs are fixed, so the factory is not invoked there. Defaults for every call go in the pipeline's options, for exampleConfigureOptionsorChatClientAgentOptions.ChatOptions:var answer = await chat.GetResponseAsync("Where are shards loaded?", new() { RawRepresentationFactory = _ => new CorfedoChatOptions { References = [new() { Kind = AiReferenceKind.Repository, Repository = "acme/payments" }], Limits = new() { ModelCallBudget = 8 } } });Other input fails with
CorfedoUnsupportedInputException(codeunsupported_input) naming it, before anything is sent: several messages without tool results, system or assistant messages, non-text content, sampling and generation options (temperature, top-p, maximum output tokens, instructions and the like), hosted tools, aRawRepresentationFactoryreturning another type, andAdditionalProperties.The answer comes from the run's completion. Streamed text is display output and includes text of steps that end with tool calls, one
MessageIdper step. If text a streaming call already yielded is discarded by the run, the call fails withCorfedoOutputDiscardedException; the run continues and its answer can be read.A run that ends without an answer (a failure, a limit, an invalid structured answer or cancellation) fails the call with
CorfedoRunExceptionand its outcome.ResponseIdis the run ID;RawRepresentationof the response and of the last streaming update is the endedAiRunStream, with the outcome, citation map and usage.FinishReason.Lengthmarks a truncated answer.Cancelling a call ends its subscription, not the run;
CancelRunAsynccancels it.
The package version matches Corfedo.Client.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Corfedo.Client (>= 0.0.2)
- Microsoft.Extensions.AI.Abstractions (>= 10.10.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.