[#682] Samples Parity: Align .NET and python agent-framework samples - #729
Open
Cecilia Avila (ceciliaavila) wants to merge 3 commits into
Open
Cecilia Avila (ceciliaavila) wants to merge 3 commits into
Cecilia Avila (ceciliaavila) wants to merge 3 commits into
Conversation
Copilot started reviewing on behalf of
Cecilia Avila (ceciliaavila)
September 18, 2026 18:04
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved moderate issues remain in cancellation handling, forecast lookup resilience, duplicate error reporting, and persisted session-history trimming.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Aligns the .NET and Python agent-framework weather samples with improved forecasting, progress reporting, error handling, configuration, and documentation.
Changes:
- Adds structured forecasts and progress updates.
- Improves Python session handling and local setup guidance.
- Updates .NET Teams metadata, commands, and error handling.
File summaries
| File | Summary and final review comments |
|---|---|
samples/python/agent-framework/src/tools/weather_lookup.py |
Refines weather and forecast lookup logic. |
samples/python/agent-framework/src/tools/progress.py |
Adds progress reporting. |
samples/python/agent-framework/src/agent.py |
Adds session persistence. Moderate (1 vote): persisted history can grow without bound despite the documented cap; trim persisted state or add a storage policy. |
samples/python/agent-framework/README.md |
Updates setup, testing, and session documentation. |
samples/python/agent-framework/env.TEMPLATE |
Updates model and anonymous-access defaults. |
samples/dotnet/Agent Framework/Tools/WeatherLookupTool.cs |
Adds structured forecasts and progress handling. Moderate (2 votes): forecast lookup unnecessarily depends on a separate current-weather request. Nit (2 votes): shared errors incorrectly say the forecast failed for current-weather requests. Moderate (1 vote): helper and caller can emit duplicate user-facing errors. |
samples/dotnet/Agent Framework/README.md |
Updates command documentation. |
samples/dotnet/Agent Framework/Program.cs |
Disables transcript logging by default. |
samples/dotnet/Agent Framework/appPackage/manifest.json |
Updates weather-focused branding and commands. |
samples/dotnet/Agent Framework/Agent/WeatherAgent.cs |
Updates the welcome message and exception handling. Moderate (2 votes): cancellation exceptions should be rethrown before the general exception handler to avoid masking cancellation or causing a second failure. |
Review details
Suppressed comments (2)
samples/dotnet/Agent Framework/Tools/WeatherLookupTool.cs:163
- This helper sends a user-facing error before the calling method throws;
WeatherAgent.OnMessageAsyncthen catches that exception and queues another generic error at lines 84-88. Invalid locations can therefore produce two error messages. Keep the user-facing error in one layer, either by removing this send or by handling the exception without re-queueing another message.
if (turnContext.Activity.ChannelId.Channel?.Contains(Channels.Webchat) == true)
{
await turnContext.SendActivityAsync(friendlyError).ConfigureAwait(false);
}
else
samples/python/agent-framework/src/agent.py:77
- The
before_strategyonly limits the messages sent to the model; it does not evict older messages fromHISTORY/session.state. Because line 149 serializes that state on every turn, long-running conversations still grow without bound even though the README describes a capped history. Add a storage/after-compaction policy, or trim the persisted state before serialization, if the 10-group cap is meant to apply to sessions as well.
CONTEXT_COMPACTION = CompactionProvider(
before_strategy=SlidingWindowStrategy(
keep_last_groups=10,
preserve_system=True,
),
- Files reviewed: 10/10 changed files
- Comments generated: 3
- 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 on lines
+84
to
+89
| catch (Exception exception) | ||
| { | ||
| System.Diagnostics.Trace.WriteLine($"Error during agent execution: {exception}"); | ||
| turnContext.StreamingResponse.QueueTextChunk( | ||
| "Sorry, I encountered an error while fetching the weather. Please try again later."); | ||
| } |
Comment on lines
+84
to
+89
| await ReportProgressAsync($"Fetching Weather Forecast for {location}"); | ||
| var currentWeather = await openWeather.GetWeatherAsync( | ||
| locationInfo.Latitude, | ||
| locationInfo.Longitude, | ||
| unit: OpenWeatherMapSharp.Models.Enums.Unit.Imperial); | ||
| if (!currentWeather.IsSuccess) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #682
This pull request introduces several improvements and refinements to both the .NET and Python agent-framework samples. The main enhancements include a friendlier and more descriptive user experience, improved error handling, streamlined weather lookup logic, and updated documentation and configuration for easier setup and testing.
Key changes:
.NET Weather Agent Improvements
WeatherAgent.csby catching exceptions during agent execution and sending a user-friendly error message if weather retrieval fails.WeatherLookupTool:DailyForecastrecord for structured forecast responses.Python Weather Agent & Documentation Updates
gpt-4.1-miniinstead ofgpt-4o, and simplified the setup for local testing by enabling anonymous access by default. [1] [2] [3]progress.pytool for reporting progress.These changes collectively make the weather agent samples more user-friendly, robust, and easier to set up and test locally.
Testing
These images show the two samples with similar behavior for normal responses and error handling.
