Skip to content

Conversation

@eoindoherty1
Copy link
Contributor

Motivation and Context

The PurviewWrapper class does not directly depend on BackgroundJobRunner. This causes dependency injection to not instantiate BackgroundJobRunner in certain circumstances. Since BackgroundJobRunner creates the workers which process background jobs, this prevents jobs from running in the background. This change adds BackgroundJobRunner as a dependency of PurviewWrapper to ensure background workers are always created when the PurviewWrapper is created.

Description

This change is relatively small. It swaps the IChannelHandler dependency for IBackgroundJobRunner and moves the channel shutdown code from IChannelHandler into IBackgroundJobRunner.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR. Not a breaking change.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a dependency injection issue where BackgroundJobRunner was not being instantiated in certain circumstances, preventing background jobs from running. The fix makes PurviewWrapper directly depend on IBackgroundJobRunner instead of IChannelHandler, ensuring the background workers are always created.

Changes:

  • Created new IBackgroundJobRunner interface with a ShutdownAsync method
  • Changed PurviewWrapper to depend on IBackgroundJobRunner instead of IChannelHandler
  • Moved channel shutdown logic from IChannelHandler into IBackgroundJobRunner.ShutdownAsync
  • Updated unit tests to use IBackgroundJobRunner mock

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
dotnet/src/Microsoft.Agents.AI.Purview/IBackgroundJobRunner.cs New interface for background job management with ShutdownAsync method
dotnet/src/Microsoft.Agents.AI.Purview/BackgroundJobRunner.cs Implements IBackgroundJobRunner and adds ShutdownAsync method that delegates to IChannelHandler
dotnet/src/Microsoft.Agents.AI.Purview/PurviewWrapper.cs Updates dependency from IChannelHandler to IBackgroundJobRunner and calls ShutdownAsync on dispose
dotnet/src/Microsoft.Agents.AI.Purview/PurviewExtensions.cs Registers BackgroundJobRunner as IBackgroundJobRunner in DI container
dotnet/tests/Microsoft.Agents.AI.Purview.UnitTests/PurviewWrapperTests.cs Updates test mocks to use IBackgroundJobRunner instead of IChannelHandler

@eoindoherty1 eoindoherty1 added this pull request to the merge queue Jan 16, 2026
Merged via the queue into microsoft:main with commit a151f10 Jan 16, 2026
14 checks passed
alliscode pushed a commit to alliscode/agent-framework that referenced this pull request Jan 16, 2026
…rosoft#3256)

* Clean up background job dependency injection

* Fix xml documentation grammar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants