Foundry memory items emit assistant content as input_text instead of output_text - #617
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes Foundry memory-item serialization so that assistant messages are represented as model output (output_text) rather than user input (input_text), aligning Foundry’s behavior with the repo’s Responses conventions and other SDK parity.
Changes:
- Update
toResponseItemto emitoutput_textwhen the role isassistant, andinput_textotherwise. - Extend
TestMemoryProviderInvokedUpdatesMemoriesto assert the serialized content-part type for both user and assistant memory items.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| provider/foundryprovider/memory.go | Selects content-part "type" based on message role, emitting output_text for assistant items. |
| provider/foundryprovider/memory_test.go | Adds assertions verifying user items serialize as input_text and assistant items as output_text. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9da4206 to
21d86f4
Compare
This comment has been minimized.
This comment has been minimized.
21d86f4 to
43fe826
Compare
This comment has been minimized.
This comment has been minimized.
Foundry memory items built from assistant messages were emitted with an input_text content part, matching only user/system messages. The Responses convention distinguishes these: assistant turns are output messages carrying output_text, while user/system turns carry input_text. Select the content-part type by role in toResponseItem so assistant items use output_text and user/system items stay on input_text.
43fe826 to
52bc68f
Compare
Parity Review — ✅ ApprovedThis PR fixes a bug in the unexported FindingsScope: Internal implementation fix — Parity: The fix explicitly improves alignment with upstream behavior. In both the Go Labels: The No parity issues identified. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
What
toResponseIteminprovider/foundryprovider/memory.goselected the messagerole among assistant/system/user but always emitted the content part with type
input_text. As a result, an assistant memory item was serialized withinput_textrather thanoutput_text.This selects the content-part type by role: assistant items now emit
output_text, while user and system items keepinput_text.Why
This aligns with the repo's Responses convention and .NET/Python parity. In
provider/openaiprovider/responses.go, assistant turns are output messagesbuilt with
OfOutputText(output_text), while user/system turns useOfInputText(input_text). Foundry memory items should follow the sameinput/output distinction so the assistant turn is represented as model output,
not user input.
Tests
Extended
TestMemoryProviderInvokedUpdatesMemoriesto decode the serializeditems and assert the content-part type: the user item is
input_textand theassistant item is
output_text. The test fails before the fix (assistant partwas
input_text) and passes after.