Standard.Agents.Decision.Brains.LlamaSharp 0.1.0

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

The Standard for Agents

Standard.Agents.Decision.Brains.LlamaSharp

A local GGUF brain for The Standard AI Agent Framework.

Nuget Nuget Core: Standard.Agents License: TSSL


Part of The Standard for Agents. In Agent = Orchestration(Data, Decision, Direction), this package supplies the Decision nature's brain — from a local GGUF model, with no HTTP and no API key. It is an optional adapter: it plugs into the core Standard.Agents package through .UseGenerator(...), and everything else — skills, tools, guardians, memory, knowledge, streaming — comes from the core, unchanged.

The core Standard.Agents package is deliberately dependency-free. The native weight (LLamaSharp / llama.cpp) lives only here, so you take the local-inference dependency only if you want it. Prefer a hosted endpoint? Use the core's .Brain(url, key, model) instead and skip this package entirely.

Install

dotnet add package Standard.Agents                               # the core framework
dotnet add package Standard.Agents.Decision.Brains.LlamaSharp    # this local brain
dotnet add package LLamaSharp.Backend.Cpu                        # or .Cuda12 / .Vulkan for GPU

Use

using Standard.Agents;
using Standard.Agents.Decision.Brains.LlamaSharp;

var agent = new StandardAgent()
    .UseGenerator(new LlamaSharpGeneratorBroker("path/to/model.gguf"));

string answer = await agent.ProcessPromptAsync("What is 47 * 89?");

That's the whole difference from a hosted agent — one line. LlamaSharpGeneratorBroker implements the core's IGeneratorBroker (both GenerateAsync and streaming GenerateStreamAsync), so the rest of the API is identical to Standard.Agents — add skills, tools, guardians, memory, knowledge, and streaming exactly as the core how-to describes:

var agent = new StandardAgent()
    .UseGenerator(new LlamaSharpGeneratorBroker("model.gguf"))   // local brain (this package)
    .Skills("Skills")                                           // everything below is core
    .Tool(new CalculatorTool())
    .Memory("agent-memory.txt")
    .Knowledge("Knowledge")
    .LogTo("log.txt");

Constructor options: contextSize, gpuLayerCount (0 = CPU), maxTokens, and promptTemplate (below). You supply the .gguf model and a backend package; llama.cpp does the rest, entirely on your machine.

Choosing the prompt template (important)

An instruct model only generates when it's given its own chat format. If generation comes back empty, the template is almost always the reason. The default is ChatML (Qwen and many modern GGUFs); switch it to match your model:

using Standard.Agents.Decision.Brains.LlamaSharp;

// ChatML (default) — Qwen, many modern instruct models
new LlamaSharpGeneratorBroker("model.gguf");

// Llama 3 instruct
new LlamaSharpGeneratorBroker("model.gguf", promptTemplate: PromptTemplates.Llama3);

// NVIDIA Nemotron
new LlamaSharpGeneratorBroker("model.gguf", promptTemplate: PromptTemplates.Nemotron);

// Base / completion model
new LlamaSharpGeneratorBroker("model.gguf", promptTemplate: PromptTemplates.Plain);

// Your own — any (systemPrompt, userPrompt) => prompt
new LlamaSharpGeneratorBroker("model.gguf",
    promptTemplate: (system, user) => $"<s>[INST] {system}\n{user} [/INST]");   // Mistral

Backend setup & troubleshooting

RuntimeError: The native library cannot be correctly loaded is a backend problem, not a model or adapter one:

  • Exactly one backend — never install LLamaSharp.Backend.Cpu and .Cuda12 together; they fight over the native llama library. CPU-only box → keep only .Cpu.
  • Put the backend in the app that runs, not just a class library — a Backend.* reference on a library doesn't reliably copy its native DLLs into the executable's output. Verify llama.dll / ggml*.dll sit next to your .exe.
  • Match versionsLLamaSharp and the Backend must be the same version.
  • Force CPU and see the load attempts, at the top of Main:
    LLama.Native.NativeLibraryConfig.All
        .WithCuda(false)
        .WithLogCallback((level, msg) => Console.Write(msg));
    

Where this fits

Core framework Standard.Agents · repo
This package the Decision nature's brain, run locally from a GGUF file
Getting started The core how-to — one capability at a time
The theory The Tri-Nature of an Agent · SPEC
The Standard practices this repo follows

License

Licensed under the The Standard Software License (TSSL) v1.1 — the same license as Standard.Agents.

LLamaSharp and llama.cpp are MIT-licensed and consumed as NuGet dependencies. The GGUF model weights you supply carry their own licenses (Llama, Gemma, Nemotron, …) — you are responsible for using them within those terms.

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.1.0 35 7/18/2026