Skip to content

.NET: Harness Feature branch - #5310

Merged
westey (westey-m) merged 18 commits into
mainfrom
feature-harness
May 1, 2026
Merged

.NET: Harness Feature branch#5310
westey (westey-m) merged 18 commits into
mainfrom
feature-harness

Conversation

@westey-m

@westey-mwestey (westey-m) commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

#5271

Description

  • Adding components that make it easier to construct an Agent Harness with samples that demonstrate their usage.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

westey (westey-m)and others added 5 commits April 14, 2026 12:07
* Add a TODO AIContextProvider
* Add unit tests
* Address PR comments
* Address PR comments
* Fix test after removing one tool
* Add a ModeProvider for managing agent modes
* Fix typo
* Fix typo
* Fix typo
* Address PR comments
* Add sample to show how to build a harness
* Improve sample
* Sample max output tokens and model
* Fix encoding
* Fix model name in readme
* Address PR comments
* Add context window size compaction strategy for harness
* Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Address PR comments
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@moonbox3Evan Mattson (moonbox3) added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net labels Apr 16, 2026
@github-actionsgithub-actionsBot changed the title Harness Feature branch Draft PR.NET: Harness Feature branch Draft PRApr 16, 2026
* Add a file memory provider
* Address PR comments
* Fix review comments.
* Add additional unit tests
* Addressing PR comments.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a “Harness” feature set to the .NET Agent Framework, including built-in AIContextProviders (todos, agent mode, file-memory) plus a context-window-derived compaction strategy, with accompanying unit tests and a runnable sample.

Changes:

  • Introduces TodoProvider, AgentModeProvider, and FileMemoryProvider (with AgentFileStore + InMemoryAgentFileStore) for reusable harness tooling.
  • Adds ContextWindowCompactionStrategy and tests validating threshold behavior.
  • Adds a new interactive “Harness” sample (shared console + research step) and wires it into solution/docs; updates JSON source-gen registrations and package references.

Reviewed changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/Todo/TodoProviderTests.csAdds unit coverage for todo harness provider tools + session persistence.
dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/FileMemory/InMemoryAgentFileStoreTests.csAdds unit coverage for in-memory file store CRUD, listing, search, and path validation.
dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/FileMemory/FileMemoryProviderTests.csAdds unit coverage for file-memory provider tools, state init/persistence, and traversal protection.
dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/AgentMode/AgentModeProviderTests.csAdds unit coverage for agent mode provider tools, helpers, constants, and state persistence.
dotnet/tests/Microsoft.Agents.AI.UnitTests/Compaction/ContextWindowCompactionStrategyTests.csAdds tests for compaction thresholds/validation and pipeline behavior.
dotnet/src/Microsoft.Agents.AI/Microsoft.Agents.AI.csprojAdds Microsoft.Extensions.FileSystemGlobbing dependency for glob filtering.
dotnet/src/Microsoft.Agents.AI/Harness/Todo/TodoState.csIntroduces persisted todo state model.
dotnet/src/Microsoft.Agents.AI/Harness/Todo/TodoProvider.csAdds todo AIContextProvider exposing add/complete/remove/query tools.
dotnet/src/Microsoft.Agents.AI/Harness/Todo/TodoItemInput.csAdds tool input model for creating todos.
dotnet/src/Microsoft.Agents.AI/Harness/Todo/TodoItem.csAdds public todo item model returned by tools/helpers.
dotnet/src/Microsoft.Agents.AI/Harness/FileMemory/InMemoryAgentFileStore.csAdds in-memory file store implementation with list/search/glob/regex + path normalization.
dotnet/src/Microsoft.Agents.AI/Harness/FileMemory/FileSearchResult.csAdds file-search result DTO for tool responses.
dotnet/src/Microsoft.Agents.AI/Harness/FileMemory/FileSearchMatch.csAdds per-line match DTO with line numbers.
dotnet/src/Microsoft.Agents.AI/Harness/FileMemory/FileMemoryState.csAdds persisted state for file-memory provider (working folder).
dotnet/src/Microsoft.Agents.AI/Harness/FileMemory/FileMemoryProvider.csAdds file-memory AIContextProvider exposing save/read/delete/list/search tools.
dotnet/src/Microsoft.Agents.AI/Harness/FileMemory/FileListEntry.csAdds list-files entry DTO including optional description.
dotnet/src/Microsoft.Agents.AI/Harness/FileMemory/AgentFileStore.csIntroduces abstract file-store contract + glob matcher helpers.
dotnet/src/Microsoft.Agents.AI/Harness/AgentMode/AgentModeState.csIntroduces persisted mode state model.
dotnet/src/Microsoft.Agents.AI/Harness/AgentMode/AgentModeProvider.csAdds mode-tracking AIContextProvider with get/set tools and public helpers.
dotnet/src/Microsoft.Agents.AI/Compaction/ContextWindowCompactionStrategy.csAdds compaction strategy that derives token thresholds from model constraints.
dotnet/src/Microsoft.Agents.AI/AgentJsonUtilities.csRegisters harness DTO/state types for JSON source generation.
dotnet/samples/02-agents/README.mdLinks new Harness sample set from samples index.
dotnet/samples/02-agents/Harness/README.mdAdds Harness samples landing page.
dotnet/samples/02-agents/Harness/Harness_Step01_Research/WebBrowsingTools.csAdds a simple web browsing tool used by the Harness research sample.
dotnet/samples/02-agents/Harness/Harness_Step01_Research/README.mdDocuments the Harness research step sample usage and workflow.
dotnet/samples/02-agents/Harness/Harness_Step01_Research/Program.csImplements interactive research agent wiring harness providers + compaction + web tools.
dotnet/samples/02-agents/Harness/Harness_Step01_Research/Harness_Step01_Research.csprojAdds project definition for the research sample.
dotnet/samples/02-agents/Harness/Harness_Shared_Console/ToolCallFormatter.csAdds formatting for tool calls in the shared console harness.
dotnet/samples/02-agents/Harness/Harness_Shared_Console/Spinner.csAdds console spinner used during streaming output.
dotnet/samples/02-agents/Harness/Harness_Shared_Console/Harness_Shared_Console.csprojAdds shared console project for Harness samples.
dotnet/samples/02-agents/Harness/Harness_Shared_Console/HarnessConsole.csAdds reusable interactive console loop with streaming + commands.
dotnet/agent-framework-dotnet.slnxAdds new Harness sample projects/files into the solution structure.
dotnet/Directory.Packages.propsPins Microsoft.Extensions.FileSystemGlobbing package version.

Comment threaddotnet/src/Microsoft.Agents.AI/Harness/Todo/TodoProvider.cs
Comment threaddotnet/src/Microsoft.Agents.AI/Harness/FileMemory/FileMemoryProvider.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI/Harness/FileMemory/InMemoryAgentFileStore.cs Outdated
* Harness: Improve prompts and add FileSystem store
* Address PR comments
* Harness: Improve path validation
* Address PR comments
* Add always approve helpers, improve sample and fix bug
* Address PR comments
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationUsage: [Issues, PRs], Target: documentation in the code base and learn docs.NETUsage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@westey-m@SergeyMenshykh@peibekwe@moonbox3