| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Adds deterministic cleanup for per-session .NET background-agent tasks.
Changes:
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| BackgroundAgentsProvider.cs | Implements session release and task cancellation. |
| BackgroundAgentRuntimeState.cs | Stores cancellation sources and release state. |
| BackgroundAgentsProviderTests.cs | Tests release behavior and validation. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
There was a problem hiding this comment.
Completed passes: 5 | Result: No high-severity findings
Scope: full PR (2 commit(s)): 32ace65c291f, 0bd46059c9ce
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Motivation & Context
BackgroundAgentsProvider starts each background task with Task.Run(() => agent.RunAsync(input, subSession)) — with no CancellationToken. There is no way for a host to signal "this session is over", so when a conversation ends or a host evicts a session, any background tasks that were still running keep executing: they continue invoking models and calling tools, producing results nobody will ever read, and any faults they raise go unobserved. In a long-lived host serving many concurrent sessions (for example a shared-agent web server), this is wasted compute and unwanted side effects for every abandoned conversation.
This is the .NET counterpart of the Python work in #7450 / #7385, adapted to the .NET design. Notably, the .NET provider does not have Python's unbounded dict[session_id, _RuntimeState] leak: runtime state is stored per-session in AgentSession.StateBag via ProviderSessionState<T>, so dropping the session already releases the memory. Porting Python's provider-level registry would actually introduce the very leak that fix removes, so this change focuses on the part that is genuinely missing in .NET — task lifecycle and cancellation.
Description & Review Guide
What are the major changes?
What is the impact of these changes?
What do you want reviewers to focus on?
Related Issue
Fixes #7596
Contribution Checklist