Skip to content

.Net: Bug: Reasoning messages not removed when using OpenAIResponseAgent with tools #12904

@DeepAQ

Description

@DeepAQ

Describe the bug
OpenAI models with reasoning capabilities will return reasoning messages in responses. OpenAIResponseAgent does not remove reasoning messages in subsequent API call after a tool call, causing an API error:

HTTP 400 (invalid_request_error: )
Parameter: input

Item with id 'rs_***' not found. Items are not persisted when `store` is set to false. Try again with `store` set to true, or remove this item from your input.

To Reproduce
Steps to reproduce the behavior:

  1. Create OpenAIResponseAgent with a reasoning model (GPT-5, o4-mini, ...) and tools
  2. Send a message to agent that triggers a tool call
  3. See error

Expected behavior
Reasoning messages should be removed in subsequent API call after a tool call.

Screenshots
N/A

Platform

  • Language: C#
  • Source: NuGet Microsoft.SemanticKernel.Agents.OpenAI 1.61.0-preview
  • AI model: OpenAI:GPT-5
  • IDE: Visual Studio
  • OS: Windows

Additional context
N/A

Metadata

Metadata

Labels

.NETIssue or Pull requests regarding .NET codebugSomething isn't working

Type

Projects

Status

Bug

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions