Skip to content

[dotnet-port-api] Port harness file memory provider - #1001

Open
Michelle Clayton (michelle-clayton-work) wants to merge 2 commits into
mainfrom
dotnet-port-api-file-memory-provider-59f46798753a3644
Open

[dotnet-port-api] Port harness file memory provider#1001
Michelle Clayton (michelle-clayton-work) wants to merge 2 commits into
mainfrom
dotnet-port-api-file-memory-provider-59f46798753a3644

Conversation

@michelle-clayton-work

Copy link
Copy Markdown
Contributor

Summary

Port the .NET FileMemoryProvider surface into Go by adding two new harness packages:

  • agent/harness/filestore with public file-store primitives (FileStore, Entry, SearchResult, SearchMatch, LineEdit) plus an in-memory implementation for provider and test use.
  • agent/harness/filememory with a session-scoped file-memory context provider, exported state/options types, file_memory_* tools, memory-index injection, and working-folder state initialization.

This was selected from upstream commit f19a129b55e8ea86624a93227954cf43a0890e8f (microsoft/agent-framework@f19a129) because it adds a user-facing capability and exported API surface that Go did not have. The PR also adds a small compiled example and updates the feature-comparison doc to reflect the new parity.

Ported .NET PRs

Breaking Changes

No.

Tests and Examples

  • Added package tests for agent/harness/filestore
  • Added package tests for agent/harness/filememory
  • Added examples/02-agents/agents/step23_file_memory
  • Ran go test ./agent/harness/filestore ./agent/harness/filememory ./examples/02-agents/agents/step23_file_memory
  • Ran go test ./...

Notes

  • This PR intentionally keeps the port narrow: it adds the file-memory provider and the minimal public file-store abstractions it depends on, but does not also port the separate .NET file-access harness provider.
  • Upstream file-editing helper work around .NET: [BREAKING] Add file editing tools and align FileAccess/FileMemory store API agent-framework#6807 informed the tool behavior, but that broader area was not ported separately here to keep the change reviewable.
  • The in-memory file store is sufficient for the new provider and public API parity; filesystem-backed or remote store implementations can be added later without changing the provider surface.

Generated by .NET to Go API Porting Agent · 1.4K AIC · ⌖ 63.6 AIC · ⊞ 21.7K ·

Closes #757

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 4, 2026 22:29
@github-actions github-actions Bot added area:agent Changes files in the agent area area:examples Changes files in the examples area size:xlarge More than 300 changed lines or 10 files labels Sep 4, 2026

Copilot AI 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.

🟡 Changes recommended

There are a couple of correctness/API-surface issues (nondeterministic directory casing in ListChildren, silent invalid glob handling, and inconsistent JSON field naming) that should be addressed before merging.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Ports the .NET FileMemoryProvider concept into Go by introducing a session-scoped file-memory harness provider and its underlying file-store primitives, plus tests and an example demonstrating the new tools.

Changes:

  • Added agent/harness/filestore primitives and an in-memory FileStore implementation with search/edit helpers.
  • Added agent/harness/filememory provider exposing file_memory_* tools with session-scoped state and index injection.
  • Updated feature parity documentation and added a compiled example (step23_file_memory).
File summaries
File Description
agent/harness/filestore/filestore.go New file-store abstractions + in-memory implementation, search/glob, and edit helpers used by file memory.
agent/harness/filestore/filestore_test.go Tests for path normalization, list/search behavior, and invalid path rejection.
agent/harness/filememory/filememory.go New session-scoped file-memory context provider exposing file_memory_* tools and index injection.
agent/harness/filememory/filememory_test.go Tests covering tool presence, instructions, indexing, file ops, and name validation.
examples/02-agents/agents/step23_file_memory/main.go Example wiring the provider and calling write/read/ls tools.
docs/dotnet-go-sdk-feature-comparison.md Updates feature parity table to reflect new filestore/filememory harness support.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread agent/harness/filememory/filememory.go
Comment thread agent/harness/filestore/filestore.go
Comment thread agent/harness/filememory/filememory.go
Comment thread agent/harness/filestore/filestore.go
@github-actions github-actions Bot added kind:code Changes production behavior or code kind:docs Changes documentation or comments kind:examples Changes examples or example-support metadata kind:tests Changes tests, fixtures, or test infrastructure pending-auto-risk Automatic risk classification is in progress risk:medium Contained production impact requiring normal review depth and removed pending-auto-risk Automatic risk classification is in progress labels Sep 4, 2026
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Scope: public API, examples

Changed Go contract: New packages agent/harness/filestore (exported FileStore interface, InMemoryStore, Entry, SearchResult, SearchMatch, LineEdit, ApplyReplace, ApplyReplaceLines) and agent/harness/filememory (exported Provider, New, State, Options, ListEntry, tool name constants WriteToolName/ReadToolName/DeleteToolName/LsToolName/GrepToolName/ReplaceToolName/ReplaceLinesToolName). New example examples/02-agents/agents/step23_file_memory. Feature-comparison doc updated accordingly.

Upstream evidence reviewed: dotnet/src/Microsoft.Agents.AI/Harness/FileMemory/FileMemoryProvider.cs, FileMemoryProviderOptions.cs, FileMemoryState.cs, FileListEntry.cs, and dotnet/src/Microsoft.Agents.AI/Harness/FileStore/{AgentFileStore.cs,InMemoryAgentFileStore.cs,StorePaths.cs,FileEditor.cs,FileStoreEntry.cs} at commit f19a129b55e8ea86624a93227954cf43a0890e8f (microsoft/agent-framework#7114). No equivalent found in python/packages/core/agent_framework/ — this is a .NET-only capability, consistent with the PR's stated intent.

Result: aligned.

Verified default instructions, tool names/descriptions, index-rebuild logic (memories.md, _description.md sidecar, 50-entry cap, alphabetical + case-insensitive sort, internal-file hiding), flat-namespace validation (no subdirectories, no reserved names), ApplyReplace/ApplyReplaceLines semantics (fail on 0 or >1 matches without replace_all, duplicate/out-of-range line-number rejection), and non-recursive Search defaults all match the linked .NET port. Minor idiomatic differences are not parity defects:

  • Go's ReadToolName/DeleteToolName vs .NET's ReadFileToolName/DeleteFileToolName — the wire-visible tool name string (file_memory_read, file_memory_delete) is identical; only the internal Go constant identifier differs.
  • Go uses a per-session mutex (keyed by weak session pointer) instead of .NET's single shared SemaphoreSlim; this is a Go-side concurrency improvement (avoids serializing writes across unrelated sessions) and does not change observable single-session behavior.
  • Go's New(store, stateInitializer, opts) panics on a nil store vs .NET's Throw.IfNull (ArgumentException) — both are the idiomatic fail-fast pattern for constructor-time misuse in each language and match existing Go harness providers (e.g. agentmode, loop).

agent/harness/filestore is a new public package not present in the linked upstream commit under its own name (upstream keeps AgentFileStore/InMemoryAgentFileStore bundled in Harness/FileStore), but the Go split into filestore + filememory is a reasonable, non-breaking modularization; the exported surface (entry types, search/replace primitives) is a faithful semantic port.

Generated by Go API Consistency Review Agent for #1001 · copilot · auto · 62.7 AIC · ⌖ 5.01 AIC · ⊞ 9.5K ·

@github-actions github-actions Bot added public-api-change Pull Request changes public APIs pending-auto-risk Automatic risk classification is in progress risk:medium Contained production impact requiring normal review depth and removed risk:medium Contained production impact requiring normal review depth pending-auto-risk Automatic risk classification is in progress labels Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Changes files in the agent area area:examples Changes files in the examples area kind:code Changes production behavior or code kind:docs Changes documentation or comments kind:examples Changes examples or example-support metadata kind:tests Changes tests, fixtures, or test infrastructure public-api-change Pull Request changes public APIs risk:medium Contained production impact requiring normal review depth size:xlarge More than 300 changed lines or 10 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dotnet-port-api] Port harness file memory provider

2 participants