Skip to content

Foundry memory items emit assistant content as input_text instead of output_text - #617

Merged
George Adams (gdams) merged 1 commit into
microsoft:mainfrom
PratikDhanaveFork:foundry-memory-assistant-output-text
Jul 29, 2026
Merged

Foundry memory items emit assistant content as input_text instead of output_text#617
George Adams (gdams) merged 1 commit into
microsoft:mainfrom
PratikDhanaveFork:foundry-memory-assistant-output-text

Conversation

@PratikDhanave

Copy link
Copy Markdown
Contributor

What

toResponseItem in provider/foundryprovider/memory.go selected the message
role among assistant/system/user but always emitted the content part with type
input_text. As a result, an assistant memory item was serialized with
input_text rather than output_text.

This selects the content-part type by role: assistant items now emit
output_text, while user and system items keep input_text.

Why

This aligns with the repo's Responses convention and .NET/Python parity. In
provider/openaiprovider/responses.go, assistant turns are output messages
built with OfOutputText (output_text), while user/system turns use
OfInputText (input_text). Foundry memory items should follow the same
input/output distinction so the assistant turn is represented as model output,
not user input.

Tests

Extended TestMemoryProviderInvokedUpdatesMemories to decode the serialized
items and assert the content-part type: the user item is input_text and the
assistant item is output_text. The test fails before the fix (assistant part
was input_text) and passes after.

Copilot AI review requested due to automatic review settings July 23, 2026 05:43
@PratikDhanave
PratikDhanave (PratikDhanave) requested a review from a team as a code owner July 23, 2026 05:43

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 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 toResponseItem to emit output_text when the role is assistant, and input_text otherwise.
  • Extend TestMemoryProviderInvokedUpdatesMemories to 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.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the parity-approved Go API consistency review found no parity issues label Jul 23, 2026
@PratikDhanave
PratikDhanave (PratikDhanave) force-pushed the foundry-memory-assistant-output-text branch from 21d86f4 to 43fe826 Compare July 24, 2026 01:41
@github-actions

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.
@PratikDhanave
PratikDhanave (PratikDhanave) force-pushed the foundry-memory-assistant-output-text branch from 43fe826 to 52bc68f Compare July 24, 2026 09:36
@github-actions

Copy link
Copy Markdown
Contributor

Parity Review — ✅ Approved

This PR fixes a bug in the unexported toResponseItem helper in provider/foundryprovider/memory.go. No exported (public) Go APIs are added, removed, or changed.

Findings

Scope: Internal implementation fix — toResponseItem is an unexported function; no exported identifiers or user-visible API contracts are affected.

Parity: The fix explicitly improves alignment with upstream behavior. In both the Go provider/openaiprovider/responses.go and the upstream .NET/Python implementations, assistant turns are serialized as output_text while user/system turns use input_text. The previous Go behavior (always emitting input_text) was a divergence from upstream semantics; this PR corrects it.

Labels: The public-api-change label is not warranted — only unexported implementation details changed. The existing parity-approved label is appropriate and will be retained.

No parity issues identified.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Go API Consistency Review Agent · 21.6 AIC · ⌖ 5.55 AIC · ⊞ 5.9K ·

@gdams
George Adams (gdams) added this pull request to the merge queue Jul 29, 2026
Merged via the queue into microsoft:main with commit f07c4be Jul 29, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parity-approved Go API consistency review found no parity issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants