Skip to content

fix(server): preserve tool result adjacency in compat converters#156

Draft
marksverdhei wants to merge 1 commit into
htfrom
fix/151-tool-result-ordering
Draft

fix(server): preserve tool result adjacency in compat converters#156
marksverdhei wants to merge 1 commit into
htfrom
fix/151-tool-result-ordering

Conversation

@marksverdhei

Copy link
Copy Markdown

What changed

  • emit Anthropic tool-result messages before mixed user text
  • apply the same ordering fix to Gemini function responses
  • add model-free conversion regression tests for both APIs

Why

OpenAI-compatible message ordering requires a tool result to remain adjacent to the preceding assistant tool call. Both converters collected tool results and appended them after ordinary text from the same source turn, producing assistant -> user -> tool instead of assistant -> tool -> user.

The separate Gemini duplicate-ID behavior for parallel same-name calls is intentionally unchanged because it requires cross-turn response pairing.

Validation

  • cmake --build build --target test-chat -j 8
  • ./build/bin/test-chat
  • git diff --check

Fixes #151

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

anthropic-compat: mixed tool_result+text user turn reorders tool result after text (wrong OAI ordering)

1 participant