Skip to content

fix(providers): serialize tool calls and tool results in conversation history#210

Merged
Aaronontheweb merged 2 commits into
devfrom
fix/openai-compatible-tool-call-serialization
Mar 13, 2026
Merged

fix(providers): serialize tool calls and tool results in conversation history#210
Aaronontheweb merged 2 commits into
devfrom
fix/openai-compatible-tool-call-serialization

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Collaborator

Summary

  • OpenAiCompatibleChatClient.ToMessage() was serializing all non-system messages as simple {"role": "...", "content": "..."} objects, dropping tool_calls from assistant messages and tool_call_id from tool result messages
  • This broke multi-turn tool calling: the first tool call would succeed, but follow-up LLM requests contained malformed history causing the model to fall back to emitting tool calls as raw text
  • Fix adds proper serialization for assistant messages with FunctionCallContent (emits tool_calls array) and tool result messages with FunctionResultContent (emits tool_call_id)

Test plan

  • New test SerializesAssistantToolCalls_AndToolResults_InConversationHistory verifies correct payload structure
  • All 6 existing OpenAiCompatibleChatClientTests pass
  • Hit-tested against live lemonade/Qwen3.5 endpoint on big-gpu — single and multi-tool calls confirmed working via netclaw -p

… history

ToMessage() was dropping tool_calls from assistant messages and tool_call_id
from tool result messages, sending only role+content for all non-system
messages. This caused multi-turn tool calling to fail because the LLM could
not correlate tool results back to calls in the conversation history.
@Aaronontheweb Aaronontheweb enabled auto-merge (squash) March 13, 2026 16:05
@Aaronontheweb Aaronontheweb merged commit 78ba0cd into dev Mar 13, 2026
2 of 3 checks passed
@Aaronontheweb Aaronontheweb deleted the fix/openai-compatible-tool-call-serialization branch March 13, 2026 16:08
@Aaronontheweb Aaronontheweb mentioned this pull request Mar 13, 2026
4 tasks
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.

1 participant