Skip to content

Python/.Net: Agent Harness blog post accompanying samples part 2#6692

Open
westey-m wants to merge 3 commits into
microsoft:mainfrom
westey-m:harness-blog-part2-samples
Open

Python/.Net: Agent Harness blog post accompanying samples part 2#6692
westey-m wants to merge 3 commits into
microsoft:mainfrom
westey-m:harness-blog-part2-samples

Conversation

@westey-m

Copy link
Copy Markdown
Contributor

Motivation & Context

#6361

Description & Review Guide

  • Add samples for the harness blog part 2

Related Issue

Fixes #

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI review requested due to automatic review settings June 23, 2026 16:55
@moonbox3 moonbox3 added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python .NET Usage: [Issues, PRs], Target: .Net labels Jun 23, 2026
@github-actions github-actions Bot changed the title Add samples for the harness blog part 2 .NET: Add samples for the harness blog part 2 Jun 23, 2026
@github-actions github-actions Bot changed the title .NET: Add samples for the harness blog part 2 Python: Add samples for the harness blog part 2 Jun 23, 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.

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.

@github-actions github-actions Bot 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.

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) and Math.Abs() (throws on int.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 why GetHashCode() 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

@westey-m westey-m changed the title Python: Add samples for the harness blog part 2 Python/.Net: Agent Harness blog post accompanying samples part 2 Jun 23, 2026
@westey-m westey-m marked this pull request as ready for review June 23, 2026 18:06
@github-actions

Copy link
Copy Markdown
Contributor

Flagged issue

The file-memory persistence story is misstated: /session-export only 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 Python python/samples/02-agents/harness/console/commands/session_handler.py:57-62 and python/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.


Source: automated DevFlow PR review

@github-actions github-actions Bot 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.

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-export and /session-import can carry across runs, but the shared session handlers only serialize the AgentSession state 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 lose watchlist.md and any other file-memory contents.

Flagged Issues

  • The file-memory persistence story is misstated: /session-export only 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 Python python/samples/02-agents/harness/console/commands/session_handler.py:57-62 and python/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants