Commit 49b5c83
Roundtrip OpenAI Responses reasoning item id for stateless (store=false) encrypted reasoning (#7629)
* Fix OpenAI Responses encrypted reasoning id round-trip for store=false resume
The streaming path dropped the reasoning item's service assigned id, so on a
stateless (store=false) resume the reconstructed reasoning item had no id and the
Azure AI Foundry project scoped Responses endpoint rejected the request with
HTTP 400 invalid_payload. RawRepresentation could not carry the id because it is
[JsonIgnore] and does not survive session serialization between turns.
Carry the reasoning item id in the reasoning content's AdditionalProperties, which
survives both content coalescing and JSON serialization, and restore it on the
outgoing request (handling both string and JsonElement values). Adds a streaming
round-trip test that serializes and rehydrates the history to model a persisted
human in the loop approval session.
Refs #7628, microsoft/agent-framework#7067
* Use first-class TextReasoningContent.ItemId to roundtrip reasoning id
Replaces the AdditionalProperties based carrier from the previous commit with a
first class optional TextReasoningContent.ItemId property, marked [Experimental]
(MEAI001). Content coalescing preserves it, and the OpenAI Responses client
populates and consumes it, so the reasoning item id survives both coalescing and
JSON serialization of the chat history and is sent back on stateless (store=false)
resume. The typed, serializable property also removes the need to special case
JsonElement values when reading the id back.
The AdditionalProperties approach is kept in history (previous commit) for backtrack.
Refs #7628, microsoft/agent-framework#7067
* Fix stale test comment to reference TextReasoningContent.ItemId
The roundtrip test comment still referenced the AdditionalProperties carrier from
the earlier commit; the current implementation roundtrips the reasoning item id via
the TextReasoningContent.ItemId property. Addresses PR review feedback.
Refs #7628, microsoft/agent-framework#7067
* Revert "Fix stale test comment to reference TextReasoningContent.ItemId"
This reverts commit bc42d22.
* Revert "Use first-class TextReasoningContent.ItemId to roundtrip reasoning id"
This reverts commit 6fe9943.
* Use named arguments for CreateReasoningContent encrypted-content call
Pass protectedData and itemId by name at the streaming encrypted-content call site to avoid misreading the positional encrypted-content argument. No behavior change.
---------
Co-authored-by: Tarek Mahmoud Sayed <tarekms@microsoft.com>1 parent 10133db commit 49b5c83
2 files changed
Lines changed: 158 additions & 10 deletions
File tree
- src/Libraries/Microsoft.Extensions.AI.OpenAI
- test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests
Lines changed: 52 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
35 | 41 | | |
36 | 42 | | |
37 | 43 | | |
| |||
198 | 204 | | |
199 | 205 | | |
200 | 206 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
| 207 | + | |
206 | 208 | | |
207 | 209 | | |
208 | 210 | | |
| |||
475 | 477 | | |
476 | 478 | | |
477 | 479 | | |
478 | | - | |
| 480 | + | |
479 | 481 | | |
480 | 482 | | |
481 | 483 | | |
482 | | - | |
| 484 | + | |
483 | 485 | | |
484 | 486 | | |
485 | 487 | | |
| |||
595 | 597 | | |
596 | 598 | | |
597 | 599 | | |
598 | | - | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
599 | 604 | | |
600 | | - | |
| 605 | + | |
601 | 606 | | |
602 | 607 | | |
603 | 608 | | |
| |||
917 | 922 | | |
918 | 923 | | |
919 | 924 | | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
920 | 943 | | |
921 | 944 | | |
922 | 945 | | |
| |||
1523 | 1546 | | |
1524 | 1547 | | |
1525 | 1548 | | |
1526 | | - | |
| 1549 | + | |
1527 | 1550 | | |
1528 | 1551 | | |
1529 | 1552 | | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
1530 | 1572 | | |
1531 | 1573 | | |
1532 | 1574 | | |
| |||
Lines changed: 106 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
576 | 576 | | |
577 | 577 | | |
578 | 578 | | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
579 | 668 | | |
580 | 669 | | |
581 | 670 | | |
| |||
6779 | 6868 | | |
6780 | 6869 | | |
6781 | 6870 | | |
| 6871 | + | |
| 6872 | + | |
| 6873 | + | |
| 6874 | + | |
| 6875 | + | |
| 6876 | + | |
| 6877 | + | |
| 6878 | + | |
| 6879 | + | |
| 6880 | + | |
| 6881 | + | |
| 6882 | + | |
| 6883 | + | |
| 6884 | + | |
| 6885 | + | |
| 6886 | + | |
| 6887 | + | |
6782 | 6888 | | |
6783 | 6889 | | |
6784 | 6890 | | |
| |||
0 commit comments