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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Corfedo.Extensions.AI" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Corfedo.Extensions.AI" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Corfedo.Extensions.AI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Corfedo.Extensions.AI --version 0.0.2
                    
#r "nuget: Corfedo.Extensions.AI, 0.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Corfedo.Extensions.AI@0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Corfedo.Extensions.AI&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Corfedo.Extensions.AI&version=0.0.2
                    
Install as a Cake Tool

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.ConversationId names the conversation; without it a call starts one, and the response carries its ID. ChatClientAgent sessions keep it.

  • The profile an administrator set for API access (Settings › Client access) answers, and a response names it as ModelId. ChatOptions.ModelId is rejected.

  • ChatOptions.Tools functions are client tools the caller runs: the response ends with FunctionCallContent and FinishReason.ToolCalls, and the next call carries only FunctionResultContent with the conversation ID, as UseFunctionInvocation sends it. Corfedo's own tool calls are informational FunctionCallContent.

  • ChatOptions.ResponseFormat with 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 CorfedoChatOptions returned by ChatOptions.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 example ConfigureOptions or ChatClientAgentOptions.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 (code unsupported_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, a RawRepresentationFactory returning another type, and AdditionalProperties.

  • The answer comes from the run's completion. Streamed text is display output and includes text of steps that end with tool calls, one MessageId per step. If text a streaming call already yielded is discarded by the run, the call fails with CorfedoOutputDiscardedException; 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 CorfedoRunException and its outcome.

  • ResponseId is the run ID; RawRepresentation of the response and of the last streaming update is the ended AiRunStream, with the outcome, citation map and usage. FinishReason.Length marks a truncated answer.

  • Cancelling a call ends its subscription, not the run; CancelRunAsync cancels it.

The package version matches Corfedo.Client.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.2 45 11/29/2026
0.0.1 51 11/29/2026