Skip to content

Updating Python SK sample to have Kernel creation scoped to invoke_agent#263

Merged
axelsrz merged 1 commit intomainfrom
users/axsuarez/sk-sample-revision
Aug 27, 2025
Merged

Updating Python SK sample to have Kernel creation scoped to invoke_agent#263
axelsrz merged 1 commit intomainfrom
users/axsuarez/sk-sample-revision

Conversation

@axelsrz
Copy link
Copy Markdown
Member

@axelsrz axelsrz commented Aug 22, 2025

This pull request refactors and improves code formatting, structure, and initialization for the multi-turn semantic kernel Python sample. The main changes include restructuring the initialization and invocation logic for the weather forecast agent, improving code readability and formatting throughout the plugins and app, and ensuring proper kernel and plugin setup for each agent invocation.

WeatherForecastAgent initialization and invocation refactor

  • Refactored the WeatherForecastAgent to initialize the agent and kernel within the invoke_agent method, ensuring a fresh kernel and plugin setup for each invocation. The agent now receives its client via the constructor, and execution settings are stored as an instance variable.
  • Improved error handling in invoke_agent by formatting the error message and retrying invocation with additional context.

Code formatting and readability improvements

  • Reformatted imports and function signatures for better readability in agent.py, adaptive_card_plugin.py, date_time_plugin.py, and weather_forecast_plugin.py. [1] [2] [3] [4] [5] [6] [7]
  • Improved code formatting and consistency in the WeatherForecastPlugin and AdaptiveCardPlugin classes, including function signatures and argument formatting. [1] [2]

Application and agent setup improvements

  • Updated agent instantiation in app.py to use clearer formatting and improved argument passing for AzureChatCompletion.
  • Enhanced message handling and streaming response formatting in app.py for better user feedback and attachment handling.

Logging and server startup

  • Added a blank line for improved readability in the logging setup in main.py.
  • Improved formatting in the server startup definition in start_server.py.

@axelsrz axelsrz requested a review from MattB-msft August 22, 2025 23:17
@github-actions github-actions bot added the Samples Changes to Samples label Aug 22, 2025
@axelsrz axelsrz marked this pull request as ready for review August 26, 2025 00:13
@axelsrz axelsrz merged commit 61af430 into main Aug 27, 2025
3 checks passed
@axelsrz axelsrz deleted the users/axsuarez/sk-sample-revision branch August 27, 2025 01:39
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