Python/.Net: Agent Harness blog post accompanying samples part 2#6692
Python/.Net: Agent Harness blog post accompanying samples part 2#6692westey-m wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds “Build your own claw” blog series samples for Post 2 (Working with your data, safely) across Python and .NET harness samples, demonstrating file access, approval-gated tools, and optional Foundry memory integration.
Changes:
- Added a new Python runnable sample (
claw_step02_working_with_data.py) plus supporting README and working data. - Added a new .NET runnable sample project for Step 02, including tools, README, program entrypoint, and working data.
- Linked the new sample series from the existing harness samples README(s).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| python/samples/02-agents/harness/README.md | Adds a link to the “Build your own claw” sample series. |
| python/samples/02-agents/harness/build_your_own_claw/README.md | Documents Part 2 sample goals, setup, and usage. |
| python/samples/02-agents/harness/build_your_own_claw/claw_step02_working_with_data.py | New Python Step 02 sample implementing file access + approvals + optional Foundry memory. |
| python/samples/02-agents/harness/build_your_own_claw/working/portfolio.csv | Sample portfolio data for Python Step 02. |
| dotnet/samples/02-agents/Harness/BuildYourOwnClaw/Claw_Step02_WorkingWithData/working/portfolio.csv | Sample portfolio data for .NET Step 02. |
| dotnet/samples/02-agents/Harness/BuildYourOwnClaw/Claw_Step02_WorkingWithData/TradingTools.cs | Adds approval-required trade tool wrapper and implementation. |
| dotnet/samples/02-agents/Harness/BuildYourOwnClaw/Claw_Step02_WorkingWithData/StockTools.cs | Adds stock quote tool and mock price book for Step 02. |
| dotnet/samples/02-agents/Harness/BuildYourOwnClaw/Claw_Step02_WorkingWithData/README.md | Documents .NET Step 02 sample goals, setup, and expected interactions. |
| dotnet/samples/02-agents/Harness/BuildYourOwnClaw/Claw_Step02_WorkingWithData/Program.cs | New .NET Step 02 console app wiring client, memory provider, file access, approvals, and tools. |
| dotnet/samples/02-agents/Harness/BuildYourOwnClaw/Claw_Step02_WorkingWithData/Claw_Step02_WorkingWithData.csproj | New .NET sample project definition and content-copy rules for working files. |
| dotnet/agent-framework-dotnet.slnx | Includes the new .NET sample project in the solution. |
There was a problem hiding this comment.
Automated Code Review
Reviewers: 5 | Confidence: 83%
✓ Correctness
The PR adds samples for blog part 2 (Python and .NET). All API usage is correct and verified against the source. However, the C# StockTools.cs has a correctness regression: it uses
string.GetHashCode()(randomized per process in .NET Core) andMath.Abs()(throws onint.MinValue) for the unknown-symbol fallback price, despite Step 1's StockTools.cs explicitly avoiding this with a manual deterministic hash and a comment explaining exactly whyGetHashCode()is unsafe.
✓ Security Reliability
This PR adds well-structured samples for both Python and .NET demonstrating file access, approvals, and durable memory. The framework's FileSystemAgentFileStore provides robust path traversal and symlink protections, and the approval mechanism correctly gates sensitive operations. No security vulnerabilities found. One minor reliability nit: Math.Abs(int.MinValue) can throw OverflowException in .NET.
✓ Test Coverage
This PR adds sample code for a blog post (Part 2 of the 'Build your own claw' series). It introduces Python and .NET samples demonstrating file access, approvals, and durable memory. The repository convention is that harness samples are runable tutorial code without dedicated unit tests — the existing Step 01 sample and all other harness samples follow this same pattern. The core harness library itself is tested separately in dotnet/tests/Microsoft.Agents.AI.Harness.UnitTests/. No new testable library logic is introduced by this PR; the sample functions (get_stock_price, place_trade, StockTools, TradingTools) are thin demonstration wrappers with mock data. Given this is documentation/tutorial code following established repo conventions, the lack of tests is acceptable.
✓ Failure Modes
This PR adds sample code for a blog post demonstrating file access, approvals, and durable memory. The code is well-structured sample/demo code. I found one low-severity failure-mode concern in the Python sample where a broad exception handler could mask real errors (auth/network failures) as 'store already exists,' causing a FoundryMemoryProvider to be returned for a non-functional store. The C# sample has a minor edge case where Math.Abs(int.MinValue) could throw. Neither issue warants blocking a samples PR.
✓ Design Approach
I found one design-level correctness issue in the new Python sample: its Foundry-memory bootstrap treats every memory-store creation failure as if the store already existed, which hides real configuration/permission problems and then reports memory as enabled even when no usable store is available.
Automated review by westey-m's agents
|
Flagged issue The file-memory persistence story is misstated: Source: automated DevFlow PR review |
There was a problem hiding this comment.
Automated Code Review
Reviewers: 5 | Confidence: 80%
✓ Correctness
This PR adds Part 2 samples (Python and .NET) for the agent harness blog series. All previously-reported issues from the review thread have been properly resolved: StockTools uses a stable character-based hash, TradingTools validates action/quantity inputs, the Python memory store creation catches only ResourceNotFoundError, and the tool description no longer claims to execute real trades. The code follows established patterns in the repository and I found no new correctness issues.
✓ Security Reliability
The sample code properly addresses all previously flagged security/reliability issues. Input validation is present for trade actions and quantities, deterministic character-based hashing replaces non-deterministic platform hashing, memory store creation uses specific exception handling (ResourceNotFoundError only), and sensitive tools are gated behind approval mechanisms. No new security or reliability issues identified.
✓ Test Coverage
This PR adds sample code for the 'Build your own claw' blog post Part 2 in both .NET and Python. No tests are included for the new tool functions (get_stock_price, place_trade) despite them containing well-defined pure validation logic and deterministic computation that would be straightforward to unit test. While this is consistent with the existing pattern where no harness samples have tests, the Python test infrastructure already tests other sample categories (getting_started), and the tool functions have clear edge cases (invalid action, non-positive quantity, unknown symbol deterministic pricing) that would benefit from coverage.
✓ Failure Modes
All previously identified failure modes from resolved review comments have been properly addressed. The Python code now catches only ResourceNotFoundError specifically (not broad Exception), both language versions validate trade inputs, the .NET StockTools uses a stable character-based hash, and tool descriptions accurately reflect simulated behavior. The .NET version uses the atomic EnsureMemoryStoreCreatedAsync for memory store creation. No new silent failures, swallowed exceptions, or operational failure modes were identified in this diff.
✗ Design Approach
The main design issue is that both Step 2 samples/documentation describe file memory as something
/session-exportand/session-importcan carry across runs, but the shared session handlers only serialize theAgentSessionstate and do not export the separate on-disk file-memory store. That means a user who exports a session and imports it in a fresh checkout or on another machine will silently losewatchlist.mdand any other file-memory contents.
Flagged Issues
- The file-memory persistence story is misstated:
/session-exportonly saves serialized session state, while file memory is stored separately on disk (dotnet/samples/02-agents/Harness/Harness_Shared_Console/Commands/SessionCommandHandler.cs:60-63,dotnet/src/Microsoft.Agents.AI.Harness/HarnessAgent.cs:298-309; similarly in Pythonpython/samples/02-agents/harness/console/commands/session_handler.py:57-62andpython/packages/core/agent_framework/_harness/_file_memory.py:171-174,207-215). Importing that session into a fresh environment restores the session ID but not the memory files.
Automated review by westey-m's agents
Motivation & Context
#6361
Description & Review Guide
Related Issue
Fixes #
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.