Skip to content

fix(llm): keep tool calls in Responses API assistant messages that have content - #5941

Open
RaphaelFakhri wants to merge 2 commits into
browser-use:mainfrom
RaphaelFakhri:fix/responses-serializer-tool-calls
Open

RaphaelFakhri wants to merge 2 commits into
browser-use:mainfrom
RaphaelFakhri:fix/responses-serializer-tool-calls

Conversation

@RaphaelFakhri

@RaphaelFakhri RaphaelFakhri commented Sep 29, 2026 •

Copy link
Copy Markdown

Summary

ResponsesAPIMessageSerializer (used by ChatAzureOpenAI for Responses API models) converts an assistant message's tool calls to text because EasyInputMessageParam has no tool call field. It only did this when content was None. If the assistant message had both content and tool calls, the tool calls were silently dropped from the model input.

Changes

  • Tool calls are now appended to the assistant content whenever they exist. For string content the text is added after a newline. For content parts an extra input_text part is appended.
  • Messages with no tool calls serialize as before.

Tests

Added two cases to tests/ci/models/test_azure_responses_api.py: string content with tool calls, and text-part content with tool calls.

pytest tests/ci/models/test_azure_responses_api.py: 2 failed, 15 passed, 2 skipped before the change; 17 passed, 2 skipped after. ruff check and ruff format --check are clean.


Summary by cubic

Fixes ResponsesAPIMessageSerializer silently dropping tool calls when an assistant message has both content and tool calls. Tool calls are now appended to the assistant content instead of only being serialized when content is None.

  • Tool calls are appended after a newline for string content, or as an extra input_text part for content parts.
  • Messages with no tool calls serialize as before.

Written for commit e5fc798. Summary will update on new commits.

Review in cubic

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 2 files

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

Re-trigger cubic

This branch has not been deployed

No deployments
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.

2 participants