HPD-Agent.Framework
0.9.5
dotnet add package HPD-Agent.Framework --version 0.9.5
NuGet\Install-Package HPD-Agent.Framework -Version 0.9.5
<PackageReference Include="HPD-Agent.Framework" Version="0.9.5" />
<PackageVersion Include="HPD-Agent.Framework" Version="0.9.5" />
<PackageReference Include="HPD-Agent.Framework" />
paket add HPD-Agent.Framework --version 0.9.5
#r "nuget: HPD-Agent.Framework, 0.9.5"
#:package HPD-Agent.Framework@0.9.5
#addin nuget:?package=HPD-Agent.Framework&version=0.9.5
#tool nuget:?package=HPD-Agent.Framework&version=0.9.5
HPD-Agent.Framework
A middleware-driven agentic AI framework built on Microsoft.Extensions.AI for building intelligent, tool-using agents.
Thread-scoped event subscriptions
Subscriptions without a thread key observe only events owned by that Agent instance. They include
the agent's per-run coordinators, but exclude events originating in independently owned subagents:
using var local = agent.Subscribe<TextDeltaEvent>(evt => Console.Write(evt.Text));
Use the complete (SessionId, ThreadId) key to observe one concrete child invocation:
var child = new ThreadKey(childSessionId, childThreadId);
using var exact = agent.Subscribe<TextDeltaEvent>(child, evt => Console.Write(evt.Text));
Request hierarchy explicitly to supervise an entire branch at every depth. Sibling branches are excluded, and each delivery retains its root-to-origin route:
using var subtree = agent.SubscribeAny(
child,
AgentEventHierarchy.ThreadAndDescendants,
evt => Observe(evt));
Thread-keyed subscriptions exclude threadless events. Live descendant delivery multiplexes events from independent thread journals; it does not merge their journal cursors. Callbacks run on the subscription's mailbox pump, publication does not wait for callback completion, and disposal stops observation without stopping execution or event bubbling. Framework infrastructure that truly needs every owner must opt into global observation explicitly.
Install
dotnet add package HPD-Agent.Framework
Use When
Use HPD-Agent.Framework when building an agent with a model client,
source-generated function and ToolHarness capabilities, sessions and threads,
durable events, permissions, middleware, and provider-neutral hosting
composition.
Provider and integration packages stay optional:
- use
HPD-Agent.Providers.*for model clients; - use
HPD-Agent.MCPfor Model Context Protocol servers; - use
HPD-Agent.OpenApifor external REST APIs described by OpenAPI; - use
HPD-Agent.AspNetCorefor hosted sessions, committed SSE, and uploads; - use
HPD-Agent.AspNetCore.OpenApito publish the hosted API contract.
Middleware
IAgentMiddleware adds cross-cutting behavior around agent turns, iterations, model
calls, functions, runtime lifecycle, and error handling. Override only the hooks your
middleware needs:
using HPD.Agent;
using HPD.Agent.Middleware;
public sealed class RequestAuditMiddleware : IAgentMiddleware
{
public Task BeforeMessageTurnAsync(
BeforeMessageTurnContext context,
CancellationToken cancellationToken)
{
Console.WriteLine(
$"{context.AgentName}: {context.UserInputMessages.Count} input message(s)");
return Task.CompletedTask;
}
}
await using var agent = await new AgentBuilder(new AgentConfig())
.WithChatClient(chatClient)
.WithMiddleware(new RequestAuditMiddleware())
.BuildAsync();
Middleware runs in registration order for Before* hooks; After* and OnErrorAsync
run in reverse order. For wrapper hooks such as WrapFunctionCallAsync, the first
registered middleware is outermost. Function middleware scopes also apply to function
wrappers, not only the before/after function hooks.
Middleware referenced from AgentConfig.Middlewares is required. A missing registry
entry, unresolved dependency, or constructor failure stops the build with a structured
AgentRunConfigurationException.
See the middleware overview, custom middleware guide, and lifecycle reference.
Supported targets
The core framework, general hosting, ASP.NET Core host, bots, audio, sandbox,
TUI, MCP, evaluation, multi-agent orchestration, and tool-harness packages
target net8.0, net9.0, and net10.0.
The following packages target net10.0 only:
HPD-Agent.ClientHPD-Agent.AspNetCore.OpenApiHPD-Agent.MultiAgent.AspNetCoreHPD-Agent.MultiAgent.HpdBaseHPD-Agent.Stores.HpdBase(net10.0)HPD-Agent.Evaluations.HpdBase(net10.0)HPD-Agent.Providers.CohereHPD-Agent.Providers.DashScopeHPD-Agent.Providers.FireworksHPD-Agent.Providers.GroqHPD-Agent.Providers.HuggingFaceHPD-Agent.Providers.MistralHPD-Agent.Providers.ReplicateHPD-Agent.Providers.Together
Analyzer packages target netstandard2.0. HPD-Agent.Audio.LiveKit targets
net8.0, net9.0, and net10.0. Its companion native-assets package targets
net8.0 and currently supplies the execution-qualified osx-arm64 LiveKit FFI
artifact. Unsupported runtime identifiers fail closed.
Audio
Install HPD-Agent.Audio plus one or more audio provider packages when the
agent accepts speech, returns synthesized speech, or uses a retained realtime
transport:
dotnet add package HPD-Agent.Audio
dotnet add package HPD-Agent.Providers.Audio.OpenAI
dotnet add package HPD-Agent.Providers.Audio.ElevenLabs
Audio input and output are opt-in through WithAudio(...) after the relevant
STT, TTS, or realtime provider has been configured. Assistant audio emits
artifact, stream, playback, interruption, and failure events. Realtime user
transcription emits delta, completion, and structured failure events.
See the audio integration guide for batch STT, TTS, realtime, playback, artifact, and diagnostic examples.
Event composition
Agent events need one immutable application schema so live events, durable thread journals, replay, and source-generated Native AOT metadata agree. Applications usually do not configure this manually:
- An executable or a project with
HpdAgentApplication=truegenerates and auto-registers one complete application composition. - A library generates and auto-registers its own event module. When no full
application composition is present,
AgentBuildercomposes the loaded generated modules automatically. - Select with
WithEventApplicationIdentity(...)only when multiple generated applications are loaded into one process. - Supply
WithEventComposition(...)for a custom or intentionally core-only event surface.
Use the builder's session-store helpers, such as
WithInMemorySessionStore() or WithFileSessionStore(path), so the store is
created with the selected composition's codec. A manually created store must use
that same codec.
See Custom agent events for defining event contracts,
choosing [DurableEvent], publishing live versus journaled events, and handling
unknown or stale event contracts.
See Runtime agent extensions for tenant-owned JSON schemas, validated live/durable output events, and trusted runtime input handlers that do not require runtime C# compilation.
ToolHarness construction
ToolHarnesses have exactly one public constructor and one generated activation
path. Harness settings use IHarnessConfig<T>; constructor dependencies are
Agent-scoped services. Invalid constructor shapes and dependency defaults fail
compilation with HPDHIN009 through HPDHIN013.
var agent = await new AgentBuilder(agentConfig)
.WithToolHarness<SearchHarness>(options =>
options.Configure(new SearchSettings { MaxResults = 20 })
.UseDependency(searchClient))
.BuildAsync();
See ToolHarness construction for settings, run overrides, dependency ownership, supplied instances, and migration.
Skills
Use a skill when the model needs focused workflow instructions plus a bounded set of functions, resources, or scripts that should remain hidden until the workflow is relevant.
public sealed partial class DataTools
{
[Skill]
public static Skill Analyze() => Skill.Create(
"data_analysis",
"Validates and analyzes datasets.",
SkillInstructions.FromText("Validate the dataset before analysis."));
}
await using var agent = await new AgentBuilder(new AgentConfig { Name = "data-agent" })
.WithToolHarness<DataTools>()
.BuildAsync();
Skills can be declared in C#, imported from SKILL.md directories, or installed
through a versioned managed store. Package versions are immutable, invalid
reloads retain the last valid capability epoch, and external scripts require a
host-provided ISkillScriptRunner.
See the complete Skills guide for directory metadata,
resources, script contracts, store selection, and
RefreshCapabilitiesAsync() reload instructions.
MCP and OpenAPI integrations
HPD-Agent imports external capabilities through optional packages:
HPD-Agent.MCPconsumes MCP servers using Streamable HTTP or stdio.HPD-Agent.OpenApiturns OpenAPI-described REST operations into agent tools.HPD-Agent.AspNetCore.OpenApipublishes the application's own ASP.NET Core API as an OpenAPI 3.1 document.
All three participate in the same capability catalog, permissions, tool visibility, and revision lifecycle. MCP tools require permission by default; OpenAPI tools do not.
See MCP and OpenAPI integrations for package selection, authentication boundaries, generated-code contracts, Native AOT behavior, and troubleshooting.
For explicit native result offloading and the bounded Content retrieval tool,
see Native tool outputs and retrieval.
Compatibility
HPD-Agent 0.9.5 is pre-1.0 stabilization. Public APIs, serialized events, and
persistence formats remain subject to breaking changes while further compatibility
testing is completed. The 1.0 compatibility commitment begins with 1.0.0. The
current conversation model is session-owned threads with event-sourced thread history.
Session Fork Graph
Use ThreadForkGraph.BuildVisibleForkGroups(...) when rendering thread/fork
navigation. Thread.ForkedFrom is direct lineage; fork groups are semantic
choice points derived from the shared conversation boundary.
| Product | Versions 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 is compatible. 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 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. |
-
net10.0
- HPD-Environment.Contracts (>= 0.9.5)
- HPD-Environment.Runtime (>= 0.9.5)
- HPD-Events (>= 0.9.5)
- HPD-Serialization (>= 0.9.5)
- JsonSchema.Net (>= 9.4.1)
- Microsoft.Extensions.AI (>= 10.11.0)
- Microsoft.Extensions.AI.Abstractions (>= 10.11.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.13)
- Microsoft.Extensions.Configuration (>= 10.0.13)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.13)
- Microsoft.Extensions.Configuration.Json (>= 10.0.13)
- Microsoft.Extensions.Configuration.UserSecrets (>= 10.0.13)
- Microsoft.Extensions.DependencyInjection (>= 10.0.13)
- Microsoft.Extensions.FileSystemGlobbing (>= 10.0.13)
- Microsoft.Extensions.Http (>= 10.0.13)
- Microsoft.Extensions.Logging (>= 10.0.13)
- NLayer (>= 3.0.0)
- System.Formats.Cbor (>= 10.0.13)
-
net8.0
- HPD-Environment.Contracts (>= 0.9.5)
- HPD-Environment.Runtime (>= 0.9.5)
- HPD-Events (>= 0.9.5)
- HPD-Serialization (>= 0.9.5)
- JsonSchema.Net (>= 9.4.1)
- Microsoft.Extensions.AI (>= 10.11.0)
- Microsoft.Extensions.AI.Abstractions (>= 10.11.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.13)
- Microsoft.Extensions.Configuration (>= 10.0.13)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.13)
- Microsoft.Extensions.Configuration.Json (>= 10.0.13)
- Microsoft.Extensions.Configuration.UserSecrets (>= 10.0.13)
- Microsoft.Extensions.DependencyInjection (>= 10.0.13)
- Microsoft.Extensions.FileSystemGlobbing (>= 10.0.13)
- Microsoft.Extensions.Http (>= 10.0.13)
- Microsoft.Extensions.Logging (>= 10.0.13)
- NLayer (>= 3.0.0)
- System.Formats.Cbor (>= 10.0.13)
-
net9.0
- HPD-Environment.Contracts (>= 0.9.5)
- HPD-Environment.Runtime (>= 0.9.5)
- HPD-Events (>= 0.9.5)
- HPD-Serialization (>= 0.9.5)
- JsonSchema.Net (>= 9.4.1)
- Microsoft.Extensions.AI (>= 10.11.0)
- Microsoft.Extensions.AI.Abstractions (>= 10.11.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.13)
- Microsoft.Extensions.Configuration (>= 10.0.13)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.13)
- Microsoft.Extensions.Configuration.Json (>= 10.0.13)
- Microsoft.Extensions.Configuration.UserSecrets (>= 10.0.13)
- Microsoft.Extensions.DependencyInjection (>= 10.0.13)
- Microsoft.Extensions.FileSystemGlobbing (>= 10.0.13)
- Microsoft.Extensions.Http (>= 10.0.13)
- Microsoft.Extensions.Logging (>= 10.0.13)
- NLayer (>= 3.0.0)
- System.Formats.Cbor (>= 10.0.13)
NuGet packages (66)
Showing the top 5 NuGet packages that depend on HPD-Agent.Framework:
| Package | Downloads |
|---|---|
|
HPD-Agent.Providers.Anthropic
Anthropic (Claude) provider for HPD-Agent |
|
|
HPD-Agent.Providers.Mistral
Mistral provider for HPD-Agent |
|
|
HPD-Agent.Providers.OpenRouter
OpenRouter provider for HPD-Agent |
|
|
HPD-Agent.Providers.Groq
Groq OpenAI-compatible chat completions provider for HPD-Agent |
|
|
HPD-Agent.Providers.Ollama
Ollama provider for HPD-Agent |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.9.5 | 490 | 11/10/2026 |
| 0.9.2 | 1,087 | 11/2/2026 |
| 0.9.1 | 1,012 | 10/21/2026 |
| 0.9.0 | 997 | 10/20/2026 |
| 0.8.1 | 1,015 | 8/6/2026 |
| 0.8.0 | 991 | 8/5/2026 |
| 0.7.0 | 1,080 | 7/19/2026 |
| 0.6.0 | 654 | 7/4/2026 |
| 0.5.5 | 662 | 6/21/2026 |
| 0.5.0 | 660 | 6/11/2026 |
| 0.3.3 | 459 | 2/25/2026 |
| 0.3.2 | 429 | 2/25/2026 |
| 0.3.1 | 436 | 2/24/2026 |
| 0.3.0 | 420 | 2/24/2026 |
| 0.2.0 | 366 | 1/13/2026 |
| 0.1.4 | 592 | 12/9/2025 |
| 0.1.3 | 597 | 12/9/2025 |
| 0.1.1-alpha | 402 | 12/8/2025 |