Files
agent-framework/dotnet/samples/02-agents
T
westey 96d242fa7f .NET: Remove required token params from HarnessAgent, make compaction opt-in (#6409)
* Move token params from HarnessAgent constructor to options

Remove the required maxContextWindowTokens and maxOutputTokens
constructor parameters from HarnessAgent and AsHarnessAgent, replacing
them with optional MaxContextWindowTokens and MaxOutputTokens properties
on HarnessAgentOptions.

When both values are provided, compaction is enabled as before (in-loop
CompactionProvider and chat reducer on the default InMemoryChatHistory
Provider). When either is null, compaction is disabled entirely, making
it opt-in.

New constructor: HarnessAgent(IChatClient, HarnessAgentOptions?,
ILoggerFactory?, IServiceProvider?)

Closes #6333

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Improving comments.

* feat: Add custom CompactionStrategy and DisableCompaction to HarnessAgentOptions

Allow users to provide their own CompactionStrategy via options, with
a clear priority system:
1. DisableCompaction=true: no compaction regardless of other settings
2. Custom CompactionStrategy provided: use it (token params ignored)
3. Both MaxContextWindowTokens and MaxOutputTokens set: default strategy
4. Otherwise: no compaction

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: Address PR review comments on compaction opt-in

- Update chatClient param XML doc to reflect compaction is opt-in
- Strengthen compaction tests to assert ChatReducer is null/not-null
  rather than just asserting construction succeeds

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
96d242fa7f ยท 2026-06-09 13:06:00 +00:00
History
..

Getting started

The getting started samples demonstrate the fundamental concepts and functionality of the agent framework.

Samples

Sample Description
Agents Step-by-step instructions for getting started with agents
Agents with Foundry Foundry agent samples using FoundryAgent and AIProjectClient.AsAIAgent(...)
Agent Providers Getting started with creating agents using various providers
Agents With Retrieval Augmented Generation (RAG) Adding Retrieval Augmented Generation (RAG) capabilities to your agents
Agents With Memory Adding memory capabilities to your agents
Agents With CodeAct (Hyperlight) Enabling sandboxed code execution (CodeAct) for your agents via Hyperlight
Agent Open Telemetry Getting started with OpenTelemetry for agents
Agent With OpenAI exchange types Using OpenAI exchange types with agents
Agent With Anthropic Getting started with agents using Anthropic Claude
Model Context Protocol Getting started with Model Context Protocol
Agent Skills Getting started with Agent Skills
Agent Harness with built-in tools Demonstrating how to build an Agent Harness with built-in planning, todo, and mode management tooling
Declarative Agents Loading and executing AI agents from YAML configuration files
AG-UI Getting started with AG-UI (Agent UI Protocol) servers and clients
Dev UI Interactive web interface for testing and debugging AI agents during development
A2A Agents Working with Agent-to-Agent (A2A) specific features