Skip to content

An opinionated C# Toolkit for Microsoft Agent Framework that makes life easier

License

Notifications You must be signed in to change notification settings

rwjdk/AgentFrameworkToolkit

Repository files navigation

AgentFramework Toolkit

An opinionated C# Toolkit for Microsoft Agent Framework that makes life easier

NuGet

OpenAI | Azure OpenAI | Google (Gemini) | Anthropic (Claude) | XAI (Grok) | Mistral | OpenRouter | GitHub

Examples of use

All agents have AIAgent as base, fully work the rest of Microsoft Agent Framework)

OpenAI

OpenAIAgentFactory factory = new OpenAIAgentFactory(new OpenAIConnection
{
    ApiKey = configuration.OpenAiApiKey,
    NetworkTimeout = TimeSpan.FromMinutes(5)
});

OpenAIAgent agent = factory.CreateAgent(new OpenAIAgentOptionsForResponseApiWithReasoning
{
    Model = "gpt-5",
    ReasoningEffort = ResponseReasoningEffortLevel.High,
    ReasoningSummaryVerbosity = ResponseReasoningSummaryVerbosity.Detailed,    
});

Google

GoogleAgentFactory factory = new(new GoogleConnection
{
    ApiKey = configuration.GoogleGeminiApiKey
});

GoogleAgent agent = factory.CreateAgent(new GoogleAgentOptions
{
    Model = GenerativeAI.GoogleAIModels.Gemini25Pro,
    Tools = [AIFunctionFactory.Create(GetWeather)]
});

Anthropic

AnthropicAgentFactory factory = new AnthropicAgentFactory("<AnthropicApiKey">);

factory.CreateAgent(new AnthropicAgentOptions
{
    Model = "claude-sonnet-4-5",
    MaxOutputTokens = 10000, // <-- Force the MaxToken property I always forget
    BudgetTokens = 5000
});

X AI

XAIAgentFactory factory = new(new XAIConnection
{
    ApiKey = configuration.XAiGrokApiKey
});

XAIAgent agent = factory.CreateAgent(new OpenAIAgentOptionsForChatClientWithoutReasoning
{
    Model = "grok-4-fast-non-reasoning",
    Tools = [AIFunctionFactory.Create(GetWeather)]
});

Mistral

MistralAgentFactory mistralAgentFactory = new MistralAgentFactory("<MistralApiKey>");
MistralAgent mistralAgent = mistralAgentFactory.CreateAgent(new MistralAgentOptions
{
    Model = Mistral.SDK.ModelDefinitions.MistralSmall
});

Azure AI (with every optional setting added for demonstration)

AzureOpenAIAgent fullBlownAgent = azureOpenAIAgentFactory.CreateAgent(new OpenAIAgentOptionsForResponseApiWithReasoning
{
    Id = "1234",
    Name = "MyAgent",
    Description = "The description of my agent",
    Instructions = "Speak like a pirate",
    Model = "gpt-5-mini",
    ReasoningEffort = ResponseReasoningEffortLevel.Low,
    ReasoningSummaryVerbosity = ResponseReasoningSummaryVerbosity.Detailed,
    Tools = [AIFunctionFactory.Create(GetWeather)],
    RawToolCallDetails = details => { Console.WriteLine(details.ToString()); },
    RawHttpCallDetails = details =>
    {
        Console.WriteLine($"URL: {details.RequestUrl}");
        Console.WriteLine($"Request: {details.RequestJson}");
        Console.WriteLine($"Response: {details.ResponseJson}");
    }
});

About

An opinionated C# Toolkit for Microsoft Agent Framework that makes life easier

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Languages