Skip to content

fix(validators): recover from malformed function calls - #13908

Merged
bogdankostic merged 3 commits into
deepset-ai:mainfrom
Jenil1905:fix/json-schema-function-call-recovery
Dec 2, 2026
Merged

bogdankostic merged 3 commits into
deepset-ai:mainfrom
Jenil1905:fix/json-schema-function-call-recovery

Conversation

@Jenil1905

@Jenil1905 Jenil1905 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Related Issues

No existing issue linked.

Proposed Changes:

In an LLM JSON recovery loop, a response such as {} or {"function": {}} currently makes JsonSchemaValidator raise KeyError instead of returning a correction prompt. Malformed entries in a function-call list can also abort the pipeline.

This change checks the function-call envelope before extracting arguments and routes malformed output through the existing validation_error handler. Argument-schema validation and custom error templates retain their existing behavior.

How did you test it?

  • Confirmed 28 regression cases fail against the original implementation.
  • Passed 140 focused validator and pipeline tests, including sync/async execution.
  • Passed focused mypy, Ruff lint, Ruff format check, and git diff --check.
  • Verified invalid schema configuration still raises rather than becoming a recovery message.

Notes for the reviewer

No public API changes. A release note is included.

Checklist

  • Added regression tests and updated the docstring.
  • Used a conventional commit-style title.
  • Added a release note.
  • Ran focused tests, lint, formatting, and type checks.
  • Contributor to confirm review of the contribution guidelines and code of conduct.
  • Full pre-commit hook suite.
  • Related issue update: not applicable.

@Jenil1905
Jenil1905 requested a review from a team as a code owner November 25, 2026 06:24
@Jenil1905
Jenil1905 requested review from bogdankostic and removed request for a team November 25, 2026 06:24
@vercel

vercel Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Nov 25, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Jenil1905

Copy link
Copy Markdown
Contributor Author

Hi @bogdankostic, just following up on this PR. It's been a few days since I opened it, and I'd appreciate it if you could take a look when you get a chance.

Happy to address any feedback or requested changes. Thanks!

@github-actions github-actions Bot added the type:documentation Improvements on the docs label Dec 2, 2026
@bogdankostic bogdankostic self-assigned this Dec 2, 2026
@bogdankostic bogdankostic reopened this Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/validators
  json_schema.py
  haystack/core/pipeline
  pipeline.py
Project Total  

This report was generated by python-coverage-comment-action

@bogdankostic bogdankostic 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.

Thanks @Jenil1905! I pushed a small commit that makes the error message show the expected function-call shape and cuts the new tests down to a few representative cases. Looks good to me.

@bogdankostic
bogdankostic merged commit f9610bd into deepset-ai:main Dec 2, 2026
47 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants