Skip to content

Python: feat: pass agent run kwargs through to context providers#1681

Merged
markwallace-microsoft merged 7 commits intomicrosoft:mainfrom
DJ2695:issue-1679
Dec 2, 2025
Merged

Python: feat: pass agent run kwargs through to context providers#1681
markwallace-microsoft merged 7 commits intomicrosoft:mainfrom
DJ2695:issue-1679

Conversation

@DJ2695
Copy link
Contributor

@DJ2695 DJ2695 commented Oct 24, 2025

_prepare_thread_and_messages and _notify_thread_of_new_messages now are passing through the agent's run kwargs, sothat they can provide the context_provider with said kwargs

#1679

Motivation and Context

The run() function calls the _prepare_thread_and_messages and _notify_thread_of_new_messages. The problem is caused by not passing through the kwargs from the run, hindering using the **kwargs in the ContextProvider.

Consequently the context_provider is invoked only with messages, but not **kwargs making it unusable in that sense.

Suggested Fix:

  • adjust _prepare_thread_and_messages to take **kwargs from run
  • adjust _notify_thread_of_new_messages to take **kwargs from run
  • invoke context_provider with **kwargs in both functions

Description

_prepare_thread_and_messages and _notify_thread_of_new_messages now are passing through the agent's run kwargs, sothat they can provide the context_provider with said kwargs

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.

`_prepare_thread_and_messages` and `_notify_thread_of_new_messages` now are passing through the agent's `run` kwargs, sothat they can provide the context_provider with said kwargs

microsoft#1679
Copilot AI review requested due to automatic review settings October 24, 2025 10:10
@github-actions github-actions bot changed the title feat: pass agent run kwargs through to context providers Python: feat: pass agent run kwargs through to context providers Oct 24, 2025
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 enhances the Agent Framework's context provider functionality by propagating agent run() kwargs through the execution pipeline. This enables context providers to receive and utilize additional runtime parameters beyond just messages.

Key Changes:

  • Modified _prepare_thread_and_messages and _notify_thread_of_new_messages to accept and forward **kwargs
  • Updated context provider invocations to include the forwarded kwargs

@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Nov 17, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _agents.py2905182%329, 390–392, 438, 492, 510, 672, 851, 854–856, 984–987, 989, 992–994, 1082, 1123, 1125, 1134–1139, 1145, 1147, 1157–1158, 1165, 1167–1168, 1176–1180, 1188–1189, 1191, 1196, 1198, 1232, 1275–1276, 1278, 1291
TOTAL15861241984% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2265 130 💤 0 ❌ 0 🔥 56.325s ⏱️

@dmytrostruk dmytrostruk enabled auto-merge December 1, 2025 17:31
@dmytrostruk dmytrostruk disabled auto-merge December 1, 2025 17:35
@markwallace-microsoft markwallace-microsoft added this pull request to the merge queue Dec 2, 2025
Merged via the queue into microsoft:main with commit 1edd28b Dec 2, 2025
23 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Agent Framework Dec 2, 2025
arisng pushed a commit to arisng/agent-framework that referenced this pull request Feb 2, 2026
)

`_prepare_thread_and_messages` and `_notify_thread_of_new_messages` now are passing through the agent's `run` kwargs, sothat they can provide the context_provider with said kwargs

microsoft#1679

Co-authored-by: David Jadczyk <david.jadczyk@lht.dlh.de>
Co-authored-by: Chris <66376200+crickman@users.noreply.github.com>
Co-authored-by: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants