Skip to content

fix: accept dict tool arguments in ChatMessage.from_openai_dict_format - #12790

Open
MohammadHijjawi97 wants to merge 1 commit into
deepset-ai:mainfrom
MohammadHijjawi97:fix/openai-dict-tool-arguments
Open

MohammadHijjawi97 wants to merge 1 commit into
deepset-ai:mainfrom
MohammadHijjawi97:fix/openai-dict-tool-arguments

Conversation

@MohammadHijjawi97

Copy link
Copy Markdown

Related Issues

No existing issue. This PR includes a regression test for the crash.

Proposed Changes:

Proposed Changes:

ChatMessage.from_openai_dict_format always passed tool-call arguments to json.loads. Some OpenAI-compatible servers already send a parsed dict, which raised TypeError. Invalid JSON strings also crashed. Accept a dict payload, treat empty/null/invalid JSON as {}.

How did you test it?

Added unit tests for dict arguments and invalid JSON. Existing empty/missing argument tests still pass.

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

Some OpenAI-compatible servers send parsed argument objects. json.loads then raised TypeError. Invalid JSON strings are treated as an empty mapping.

Co-authored-by: Cursor <cursoragent@cursor.com>
@MohammadHijjawi97
MohammadHijjawi97 requested a review from a team as a code owner September 17, 2026 11:05
@MohammadHijjawi97
MohammadHijjawi97 requested review from sjrl and removed request for a team September 17, 2026 11:05
@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

@MohammadHijjawi97 is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @MohammadHijjawi97, thanks for your interest in contributing to Haystack! 🙏

⚠️ You currently have 5 open pull requests in this repository (#12794, #12793, #12792, #12791 and this one). Our review capacity is limited, so please hold off opening more PRs until we've had a chance to review your first 2 open PRs. This helps us give each contribution the attention it deserves. Thank you!

This is an automated message to help us keep the review queue healthy.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant