Commit dc27740
Python: Fix streaming path to emit mcp_server_tool_result on output_item.done instead of output_item.added (microsoft#4821)
* Fix streaming path to deliver mcp_server_tool_result content (microsoft#4814)
Remove premature mcp_server_tool_result emission from the
response.output_item.added/mcp_call handler — at that point the MCP
server has not yet responded and output is always None.
Add a handler for response.mcp_call.completed that emits
mcp_server_tool_result with the actual tool output, matching the
non-streaming path behavior.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix streaming path to deliver mcp_server_tool_result content (microsoft#4814)
Stop eagerly emitting mcp_server_tool_result on response.output_item.added
(when output is always None). Instead, handle response.output_item.done for
mcp_call items, which carries the full McpCall with populated output.
This matches the non-streaming path which guards with 'if item.output is not
None' before emitting the result.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix test docstring to match actual implementation event name
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review: call_id fallback and raw_representation consistency (microsoft#4814)
- Add call_id fallback in response.output_item.done mcp_call handler to
match the output_item.added handler pattern
- Use done_item instead of event for raw_representation to keep
consistent with other output_item branches and non-streaming path
- Add test for call_id fallback when id attribute is missing
- Add raw_representation assertions to existing done handler tests
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review: call_id fallback for non-streaming path and test coverage (microsoft#4814)
- Apply defensive call_id fallback (getattr with id/call_id/empty) to
non-streaming mcp_call path for consistency with streaming path
- Add raw_representation assertion to call_id fallback test
- Add test for empty-string fallback when neither id nor call_id exist
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent c1435ac commit dc27740
2 files changed
Lines changed: 136 additions & 32 deletions
File tree
- python/packages/openai
- agent_framework_openai
- tests/openai
Lines changed: 17 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1728 | 1728 | | |
1729 | 1729 | | |
1730 | 1730 | | |
1731 | | - | |
| 1731 | + | |
1732 | 1732 | | |
1733 | 1733 | | |
1734 | 1734 | | |
| |||
2118 | 2118 | | |
2119 | 2119 | | |
2120 | 2120 | | |
2121 | | - | |
2122 | | - | |
2123 | | - | |
2124 | | - | |
2125 | | - | |
2126 | | - | |
2127 | | - | |
2128 | | - | |
2129 | | - | |
2130 | | - | |
2131 | | - | |
2132 | | - | |
2133 | | - | |
2134 | | - | |
2135 | | - | |
2136 | | - | |
2137 | | - | |
2138 | | - | |
2139 | | - | |
2140 | | - | |
2141 | | - | |
| 2121 | + | |
2142 | 2122 | | |
2143 | 2123 | | |
2144 | 2124 | | |
| |||
2408 | 2388 | | |
2409 | 2389 | | |
2410 | 2390 | | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
2411 | 2406 | | |
2412 | 2407 | | |
2413 | 2408 | | |
| |||
Lines changed: 119 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1184 | 1184 | | |
1185 | 1185 | | |
1186 | 1186 | | |
1187 | | - | |
1188 | | - | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
1189 | 1192 | | |
1190 | 1193 | | |
1191 | | - | |
1192 | 1194 | | |
1193 | 1195 | | |
1194 | 1196 | | |
| |||
1199 | 1201 | | |
1200 | 1202 | | |
1201 | 1203 | | |
1202 | | - | |
1203 | | - | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
1204 | 1207 | | |
1205 | 1208 | | |
1206 | 1209 | | |
| |||
1209 | 1212 | | |
1210 | 1213 | | |
1211 | 1214 | | |
1212 | | - | |
1213 | | - | |
1214 | | - | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
1215 | 1218 | | |
1216 | 1219 | | |
1217 | 1220 | | |
1218 | 1221 | | |
1219 | 1222 | | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
1220 | 1328 | | |
1221 | | - | |
1222 | | - | |
| 1329 | + | |
1223 | 1330 | | |
| 1331 | + | |
| 1332 | + | |
1224 | 1333 | | |
1225 | 1334 | | |
1226 | 1335 | | |
| |||
0 commit comments