Skip to content
demaconsultingPublic

About

No description or website provided.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

89 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AgentKit

GitHub forks GitHub stars GitHub contributors License Build Quality Gate Security NuGet AgentKit banner: the AgentKit name with the tagline 'Every tool, guarded. Every chat, compacted.' and the C# call 'new ToolPackBuilder(policy).Add(new FilePack()).Build()'. A model's tool calls such as text_file_read on notes.md, the application's read-write and read-only path grants, tool limits such as a 64 KB read ceiling, and long chats flow on curved arrows into the AgentKit .NET library, and arrows lead out to what it produces: confined results where a permitted read returns and a path outside every grant is refused, a guarded tool list, a session compacted into a verbatim tail and three tiers of consolidated records, and agents on any provider such as an IChatClient or GitHub Copilot. A footnote reads 'Unsafe calls cannot be expressed.'

Overview

AgentKit is a family of .NET libraries that give an AI agent hardened, provider-neutral tools that are safe by construction: an unsafe operation is not refused at call time, it cannot be expressed. The application decides which tools an agent receives and the controls they carry, and AgentKit makes each tool behave predictably within them. It also gives the agent a session of its own that compacts its context, so a long-running agent behaves the same way on every provider.

Features

  • πŸ›‘οΈ Safe by Construction: Operations the policy forbids cannot be expressed, not merely refused at call time
  • πŸŽ›οΈ Application-Set Controls: Path grants, tool limits, and host capabilities bound every tool
  • 🧰 Ready-Made Tool Families: Text file, file, Markdown, image, todo, memory, and agent delegation
  • 🧩 Custom Tools: Build your own tools through the same guarded factory and publish them as packs
  • πŸ”Œ Provider-Neutral: Plain AIFunction tools for Microsoft Agent Framework, Copilot, and any IChatClient
  • 🧠 Self-Compacting Sessions: Tiered context compaction keeps a long conversation alive on any provider
  • πŸ—„οΈ Large Output Retention: Opt-in, any provider; held in memory for tool_output_read and tool_output_search
  • πŸ“ Honest Context Windows: Sessions account against the window a provider really runs, Ollama included
  • πŸ–ΌοΈ Images That Arrive: Tool-returned images reach the model even on providers that would drop them
  • πŸ§ͺ Testable Offline: An in-memory provider session exercises the whole session lifecycle without a model
  • πŸ“š Agent-Readable API Reference: Every package ships a gradually-disclosed Markdown API reference
  • πŸ–₯️ Multi-Platform Support: Builds and runs on Windows, Linux, and macOS, targeting .NET 8, 9, and 10
  • πŸ“‹ Continuous Compliance: CI generates evidence using Continuous Compliance

Installation

Install the core libraries and the adapter for your provider using the .NET CLI:

dotnet add package DemaConsulting.AgentKit.Core
dotnet add package DemaConsulting.AgentKit.Tools
dotnet add package DemaConsulting.AgentKit.Agents.ChatClient   # any IChatClient provider

For the GitHub Copilot runtime, add DemaConsulting.AgentKit.Agents.Copilot instead of the IChatClient adapter, and reference Microsoft.Copilot.SDK 2.0.1 directly from the host application: the SDK provisions its runtime only into a project that references it directly, and AgentKit starts and owns that runtime itself. On Ollama, also add DemaConsulting.AgentKit.Agents.Ollama so a session is told the context window the instance is actually running.

Usage

Decide what the agent may touch, decide which tools it receives, and hand both to a provider. The example runs on a local Ollama model through OllamaSharp (dotnet add package OllamaSharp); any other IChatClient drops in on the same line:

using DemaConsulting.AgentKit.Agents.ChatClient;
using DemaConsulting.AgentKit.Core;
using DemaConsulting.AgentKit.Tools.File;
using DemaConsulting.AgentKit.Tools.TextFile;
using Microsoft.Extensions.AI;
using OllamaSharp;

// What the agent may touch: relative paths anchor to /workspace, which is granted read-write.
var policy = new PathPolicy("/workspace", [PathRule.ReadWrite("/workspace")]);

// Which tools it receives: two of the shipped families, composed onto that policy.
IList<AIFunction> tools =
[
    .. new ToolPackBuilder(policy)
        .Add(new TextFilePack())
        .Add(new FilePack())
        .Build()
];

// Any IChatClient works (OpenAI, Azure OpenAI, ...); this one is a local Ollama model.
IChatClient chatClient = new OllamaApiClient(new Uri("http://localhost:11434"), "qwen3.5:9b");

// A Microsoft Agent Framework agent over that client.
var agent = ChatClientAgentFactory.Create(
    chatClient,
    tools,
    instructions: "You are a document assistant. Use the tools provided.");

var response = await agent.RunAsync("List the files in the workspace and summarize the largest one.");
Console.WriteLine(response.Text);

Every tool in that list observes the same policy: a request that names a path outside /workspace is refused with a reason the model can act on. The policy is a path guardrail, not an OS sandbox: a link inside a grant is not a boundary, so read Path Policy in the User Guide for the link and race caveats. To keep a long conversation alive past the model's context window, run the agent on a CompactingAgentSession, as the User Guide describes.

Architecture

AgentKit architecture: your application adds AgentKit.Tools packs, which are built through the AgentKit.Core tool safety contract that enforces its controls, and builds an agent or session through an AgentKit.Agents adapter, which feeds the Core session lifecycle: Agents.ChatClient builds on Microsoft Agent Framework and any IChatClient provider, Agents.Copilot provides its own AIAgent on a Copilot runtime it starts and owns through the Microsoft Copilot SDK, and Agents.Ollama reads an Ollama server's window, none of which is part of AgentKit

Your application chooses the tools and sets their controls; AgentKit.Core enforces those controls for every tool and runs the self-compacting session that each provider adapter plugs into.

Building

pwsh ./build.ps1

User Guide

The AgentKit User Guide, covering the safety model, every tool family, building an agent on each provider, and sessions with context compaction, is available on the AgentKit releases page.

Samples

Three runnable samples show AgentKit end to end:

  • πŸ“„ Document Assistant: Consuming the shipped tools under a two-location policy
  • πŸ”¬ Research Assistant: Planning, memory, and delegation on a self-compacting session
  • πŸ› οΈ Custom Tools: Writing your own guarded tools and publishing them as packs

Documentation

Each release publishes build notes, the User Guide, requirements, a trace matrix, the software and verification design documents, the code review plan and report, and a code quality report. Each NuGet package also ships its API reference in its api/ folder: an index, then a page per namespace, type, and member, with every example compiled against the real API by the build.

Contributing

Contributions are welcome. See CONTRIBUTING.md for development setup, coding standards, and the pull request process, and review the Code of Conduct.

License

Copyright (c) DEMA Consulting. Licensed under the MIT License. See LICENSE for details.

By contributing to this project, you agree that your contributions will be licensed under the MIT License.

Support

Security

For security concerns and vulnerability reporting, see the Security Policy.

About

No description or website provided.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages