AgentFrameworkToolkit.Codex 1.25.2

dotnet add package AgentFrameworkToolkit.Codex --version 1.25.2
                    
NuGet\Install-Package AgentFrameworkToolkit.Codex -Version 1.25.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="AgentFrameworkToolkit.Codex" Version="1.25.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AgentFrameworkToolkit.Codex" Version="1.25.2" />
                    
Directory.Packages.props
<PackageReference Include="AgentFrameworkToolkit.Codex" />
                    
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 AgentFrameworkToolkit.Codex --version 1.25.2
                    
#r "nuget: AgentFrameworkToolkit.Codex, 1.25.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 AgentFrameworkToolkit.Codex@1.25.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=AgentFrameworkToolkit.Codex&version=1.25.2
                    
Install as a Cake Addin
#tool nuget:?package=AgentFrameworkToolkit.Codex&version=1.25.2
                    
Install as a Cake Tool

Codex

Experimental while the implementation stabilizes. APIs may change; usage reports compiler diagnostic AFT999.

Control a local Codex runtime through Microsoft's AIAgent API using the Codex app-server protocol. Install Codex CLI (target version: 0.163.0) and run codex login, or set CodexConnection.ApiKey. On Windows, set ExecutablePath to the native codex.exe if automatic discovery fails.

dotnet add package AgentFrameworkToolkit.Codex

Run and resume

using AgentFrameworkToolkit.Codex;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;

#pragma warning disable AFT999 // Experimental Codex provider.

CodexAgentFactory factory = new();
await using CodexAgent agent = factory.CreateAgent(new CodexAgentOptions
{
    WorkingDirectory = @"C:\projects\my-app",
    Instructions = "Complete the task and summarize the result."
});

AgentSession session = await agent.CreateSessionAsync();
AgentResponse response = await agent.RunAsync("Create artifacts/report.md", session);
Console.WriteLine(response);

string threadId = session.GetThreadId()!;
AgentSession resumed = await agent.CreateSessionAsync(threadId);
await agent.RunAsync("Add an executive summary", resumed);

WorkingDirectory is required. Codex stores conversation history; send only new input. Resuming requires the original Codex storage and credentials.

Use RunStreamingAsync for incremental responses, OnRunEvent for typed activity, and response.GetFileChanges() for reported file edits. Shell-created files may not appear in that list.

Approvals and questions

Defaults are ApprovalPolicy.OnRequest and Permissions.WorkspaceWrite, matching Codex's Auto preset. User questions are disabled unless OnUserInputRequested is supplied.

With ApprovalPolicy.OnRequest, handle approvals through standard Agent Framework content:

while (response.Messages.SelectMany(message => message.Contents)
    .OfType<ToolApprovalRequestContent>().ToList() is { Count: > 0 } approvals)
{
    // Apply your application's approval decision to each request.
    ChatMessage decision = new(ChatRole.User,
        [.. approvals.Select(request => request.CreateResponse(approved: true))]);
    response = await agent.RunAsync(decision, session);
}

Pending approvals require the same agent and session instance and cannot be serialized.

To allow structured questions, supply OnUserInputRequested. It receives a CodexUserInputRequest; return request.AnswerQuestions(...) with answers keyed by question ID. Handlers should respect cancellation and provide their own interaction timeout. Without a handler, requests fail immediately; ordinary response text may still contain questions.

Tools and configuration

Register C# functions in Tools; wrap them in ApprovalRequiredAIFunction to require approval. ToolCallingMiddleware and RawToolCallDetails apply to these functions. They execute in your .NET process, outside Codex permissions. Re-supply them when resuming with a new agent.

CodexConnection configures the runtime and authentication. Agent options configure threads; native overrides are available through Config, ThreadStartParameters, ThreadResumeParameters, TurnStartParameters, and CodexAgentRunOptions.Parameters.

Each factory-created agent owns its process. Cancelling or abandoning an active stream closes its client; create a new agent and resume the saved thread to continue.

Register with services.AddCodexAgentFactory().

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
1.25.2 5 10/21/2026