Skip to content

[#682] Samples Parity: Align .NET and python agent-framework samples - #729

Open
Cecilia Avila (ceciliaavila) wants to merge 3 commits into
mainfrom
southworks/update/agent-framework-samples
Open

Cecilia Avila (ceciliaavila) wants to merge 3 commits into
mainfrom
southworks/update/agent-framework-samples

Conversation

@ceciliaavila

Copy link
Copy Markdown
Collaborator

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

  • Enhanced the weather agent's welcome message with a cat emoji and clarified instructions for users.
  • Improved error handling in WeatherAgent.cs by catching exceptions during agent execution and sending a user-friendly error message if weather retrieval fails.
  • Refactored and simplified the WeatherLookupTool:
    • Added a new DailyForecast record for structured forecast responses.
    • Combined and streamlined current weather and forecast retrieval methods, with better progress reporting and error feedback to users.
    • Improved API key management and error messages for missing configuration.
  • Updated Teams app manifest and bot command hints:
    • Changed the bot's name and description to better reflect its weather focus and cat theme.
    • Updated compose box commands to "Current weather" and "5-day forecast" for clarity.
    • Removed unused compose extensions. [1] [2] [3]
  • Commented out transcript logging middleware by default for easier local testing.

Python Weather Agent & Documentation Updates

  • Clarified that conversation history is capped at 10 messages and is serializable per conversation.
  • Updated model deployment and configuration instructions to use gpt-4.1-mini instead of gpt-4o, and simplified the setup for local testing by enabling anonymous access by default. [1] [2] [3]
  • Improved quickstart and playground instructions for easier onboarding and local testing, including direct command-line examples and clarification on authentication requirements.
  • Updated the project structure documentation to include the new progress.py tool 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.
image

image

Copilot AI lite review requested due to automatic review settings September 18, 2026 18:04
@github-actions github-actions Bot added the Samples Changes to Samples label Sep 18, 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

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.OnMessageAsync then 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_strategy only limits the messages sent to the model; it does not evict older messages from HISTORY/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)
Comment thread samples/dotnet/Agent Framework/Tools/WeatherLookupTool.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Samples Changes to Samples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants