Skip to content

[BUG] Go ADK OpenAI adapter sends prior assistant text turns as user messages in multi-turn history #3367

Open

Description

@mandipadk

Bug Description

In the Go ADK OpenAI adapter (go/adk/pkg/models/openai_adk.go), genaiContentsToOpenAIMessages only turns a model turn into an assistant message when it has function calls. A model turn with plain text falls into the else branch, which always builds a user message. So in a multi-turn chat, the model's own earlier replies get sent back to the provider as if the user said them.

This affects the Chat Completions format, which is the default for the OpenAI provider and is also used by Azure OpenAI. The Python runtime's OpenAI adapter already sends these as assistant. The Anthropic adapter had the same problem in #3026.

Steps To Reproduce

I pointed an OpenAIModel at a local test server, sent a user/model/user history through GenerateContent, and logged the request body.

Request sent today:

user      -> What is 2+2?
user      -> 4
user      -> And times 3?

Expected Behavior

user      -> What is 2+2?
assistant -> 4
user      -> And times 3?

Additional Context

Checked on main at 4f373d1. The line has been like this since the file was added in #1284. I have a small fix with a unit test ready and will open a PR.

Activity

  1. mandipadk commented on Oct 26, 2026

    @mandipadk
    Author

    /assign

  2. AlbertDoesProgramming commented on Nov 9, 2026

    @AlbertDoesProgramming

    Seeing this on v1.0.0-rc3 too, end to end, with an OpenAI-compatible stub that logs each request: turn 2 of a Session arrives as [system, user, user, user] with the agent's first reply as the middle user message, and turn 3 as [system, user×5], streamed or not. Mistral and the Foundry OpenAI path go through the same function, so #3368 covers those too, and #3289 is the same fix for Anthropic. Would be great to get both reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions