Skip to content

[BREAKING] Python: Remove request_type param from ctx.request_info() - #1824

Merged
Tao Chen (TaoChenOSU) merged 2 commits into
microsoft:mainfrom
TaoChenOSU:taochen/python-remove-request-type-in-request-info
Oct 31, 2025
Merged

[BREAKING] Python: Remove request_type param from ctx.request_info()#1824
Tao Chen (TaoChenOSU) merged 2 commits into
microsoft:mainfrom
TaoChenOSU:taochen/python-remove-request-type-in-request-info

Conversation

@TaoChenOSU

@TaoChenOSU Tao Chen (TaoChenOSU) commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

Motivation and Context

The new request_info API is clunky due to the request_type parameter, which requires developers to provide the type of the request payload when calling the API. This is unnecessary because we can get the type during runtime.

Description

Remove the request_type parameter on the request_info API.

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.

@TaoChenOSU Tao Chen (TaoChenOSU) self-assigned this Oct 31, 2025
@TaoChenOSU Tao Chen (TaoChenOSU) added the python Usage: [Issues, PRs], Target: Python label Oct 31, 2025
Copilot AI review requested due to automatic review settings October 31, 2025 00:18
@TaoChenOSU Tao Chen (TaoChenOSU) added the workflows Usage: [Issues, PRs], Target: Workflows label Oct 31, 2025
@github-actions github-actions Bot changed the title Remove request_type param from ctx.request_info() Python: Remove request_type param from ctx.request_info() Oct 31, 2025
@TaoChenOSU Tao Chen (TaoChenOSU) changed the title Python: Remove request_type param from ctx.request_info() [BREAKING] Python: Remove request_type param from ctx.request_info() Oct 31, 2025
@markwallace-microsoft

Mark Wallace (markwallace-microsoft) commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework/_workflows
   _events.py1241587%59–60, 78, 86, 90, 180–181, 232, 257, 294, 307, 315, 323, 350, 362
   _executor.py138695%203, 319, 334, 336, 451, 461
   _handoff.py45614568%61–63, 70–71, 73, 75, 80–81, 83, 133, 141–146, 149–150, 164, 173, 192–195, 204–206, 217, 220, 230–241, 243, 249, 255, 282, 296–298, 333, 338–340, 376, 385–390, 392–393, 404, 421, 449, 456, 458–460, 472, 500, 531–533, 536–539, 541–543, 776, 782, 786, 792, 796, 808, 856, 859, 947, 952, 962, 968–971, 979–980, 984–986, 988–998, 1000–1001, 1003, 1005, 1020–1021, 1024–1025, 1028, 1048–1054, 1056, 1062, 1096–1097, 1150–1151, 1262, 1270, 1279–1282, 1337, 1350, 1354, 1359–1360
   _magentic.py94027370%69–78, 83, 87–98, 322, 327, 344, 346, 361, 369–378, 456, 460, 474, 480, 495, 575, 588, 605, 614–615, 617–619, 621, 632, 699–703, 706–710, 790–793, 796–800, 802–804, 811, 850, 897, 933–935, 937, 1004, 1077, 1079–1080, 1088, 1124, 1133–1135, 1154, 1165, 1175–1176, 1178–1179, 1198, 1251, 1271, 1274, 1303, 1306, 1314–1318, 1324, 1352–1354, 1356, 1358, 1366–1369, 1371, 1375–1376, 1379–1382, 1384–1385, 1391–1393, 1396–1397, 1402–1403, 1411, 1419, 1434, 1446, 1458–1461, 1490–1491, 1496–1498, 1529, 1555, 1570, 1586, 1603, 1673, 1679–1680, 1694, 1696, 1699, 1701–1702, 1705–1706, 1710, 1713, 1734, 1771–1772, 1774, 1778–1780, 1796, 1807, 1817, 1861, 1866–1867, 2193–2194, 2198, 2213, 2218, 2221, 2275, 2286, 2297–2299, 2312–2313, 2318, 2329–2331, 2342–2344, 2356–2363, 2365–2366, 2374, 2382–2383, 2385–2387, 2389–2392, 2396–2404, 2408–2409, 2412–2416, 2418–2419, 2421–2423, 2425–2428, 2430–2432, 2434–2435, 2437–2439, 2451–2453, 2464–2467, 2478–2481, 2493–2496, 2504–2507, 2514–2515, 2522, 2526
   _request_info_mixin.py77593%54, 99, 220, 227, 234
   _workflow_context.py1621391%60–61, 69, 73, 87, 163, 188, 295, 397, 406, 411, 426, 439
   _workflow_executor.py1764872%90, 395, 414, 418, 424, 428, 441, 445, 469–470, 473–475, 482–485, 488–490, 493–494, 496, 499–501, 504–508, 512–513, 522, 527, 531, 577, 601–606, 609, 612, 620, 625, 636
TOTAL11951184484% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
1441 98 💤 0 ❌ 0 🔥 28.435s ⏱️

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.

Pull Request Overview

This PR refactors the request_info API to automatically infer the request_type from the request_data parameter, removing the need for callers to explicitly pass it. The request_type is now derived using type(request_data) internally.

  • Simplified the request_info() method signature by removing the redundant request_type parameter
  • Updated RequestInfoEvent to derive request_type from request_data automatically
  • Added validation during deserialization to ensure type consistency between serialized request_type and actual data type
  • Updated all call sites across samples and tests to use the new simplified API

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
_workflow_context.py Removed request_type parameter from request_info() method signature and added internal derivation logic
_events.py Modified RequestInfoEvent to automatically set request_type from data; added type mismatch validation in deserialization
_request_info_mixin.py Updated documentation example to reflect new API signature
_executor.py Updated example code in docstring to use response_type keyword argument
_workflow_executor.py Updated example code in docstring to use response_type keyword argument
_handoff.py Updated request_info() call to use simplified API
_magentic.py Updated request_info() call to use simplified API
Sample files (7 files) Updated all sample code to use the new simplified API with keyword arguments
Test files (7 files) Updated test code to remove request_type parameter from calls and test data

Comment thread python/packages/core/agent_framework/_workflows/_events.py
Comment thread python/packages/core/agent_framework/_workflows/_workflow_context.py Outdated
Comment thread python/packages/core/tests/workflow/test_request_info_event_rehydrate.py Outdated
@TaoChenOSU
Tao Chen (TaoChenOSU) added this pull request to the merge queue Oct 31, 2025
Merged via the queue into microsoft:main with commit 68b6a55 Oct 31, 2025
20 checks passed
Aris Nguyen (arisng) pushed a commit to arisng/agent-framework that referenced this pull request Feb 2, 2026
…icrosoft#1824)

* Remove request_type param from ctx.request_info()

* Address comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python workflows Usage: [Issues, PRs], Target: Workflows

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants