Skip to content

fix: accept state inputs handled by tool keyword arguments - #13412

Closed
skulitom wants to merge 2 commits into
deepset-ai:mainfrom
skulitom:fix/tool-state-keyword-arguments
Closed

skulitom wants to merge 2 commits into
deepset-ai:mainfrom
skulitom:fix/tool-state-keyword-arguments

Conversation

@skulitom

Copy link
Copy Markdown

Related Issues

Fixes #13411

Proposed Changes

Tool currently rejects inputs_from_state={"tenant_id": "tenant"} for a function such as search(query, **context) unless tenant is also in the JSON schema. The function accepts that keyword, but construction fails before an agent can invoke it.

Treat signatures with VAR_KEYWORD as accepting unrestricted keyword names. This allows state-only arguments to stay out of the model-facing schema. Validation for explicit signatures and non-string mapping values remains in place. Update the helper docstring and include a release note.

How did you test it?

Using Hatch on WSL Ubuntu 22.04 / Python 3.12.15:

  • Four new regression cases fail on unchanged main with the reported ValueError, then pass with the fix. They cover sync/native async functions with empty/partial schemas and successful invocation.
  • hatch run test:unit test/tools test/components/agents test/utils/test_callable_serialization.py --cov-report= --tb=short -q: 670 passed, 2 skipped, 18 deselected. The skips require Python 3.15; provider integration tests are deselected.
  • A separate local public-API harness passes sync Agent execution, async Agent execution with a sync tool, and native async tool execution. It verifies the state argument reaches the tool without appearing in its advertised schema. Only the four regression cases above are added to this PR.
  • hatch run test:types haystack/tools/tool.py test/tools/test_tool.py: passed.
  • hatch run fmt-check haystack/tools/tool.py test/tools/test_tool.py: passed.
  • Pre-commit checks for all three changed files and hatch run reno lint .: passed.

Notes for the reviewer

The existing preference for the synchronous callable when both callables are provided is unchanged. ComponentTool continues to validate against component input sockets through its override.

AI disclosure: Codex generated the implementation, regression tests, release note, and this description, and ran the local validation above.

Checklist

  • Contribution guidelines and code of conduct inspected during preparation.
  • Focused regression tests and helper docstring update included.
  • Conventional commit title and release note included.
  • Pre-commit checks pass for all changed files.
  • Linked issue includes reproduction steps and validation results.
  • CLA signature (will sign when prompted).

@skulitom
skulitom requested a review from a team as a code owner October 23, 2026 15:07
@skulitom
skulitom requested review from anakin87 and removed request for a team October 23, 2026 15:07
@vercel

vercel Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @skulitom, thanks a lot for your contribution! 🙏

We noticed that the Contributor License Agreement (CLA) check (license/cla) hasn't passed yet, so we've temporarily moved this PR to draft and paused the review assignment.

To get your PR reviewed, please sign the CLA via the link in the license/cla check below (or in the CLA bot comment). As soon as the check turns green, this PR will automatically be marked ready for review again and a reviewer will be re-assigned.

@HaystackBot
HaystackBot removed the request for review from anakin87 October 23, 2026 16:33
@HaystackBot HaystackBot added the cla-pending PR is in draft until the contributor signs the CLA label Oct 23, 2026
@HaystackBot
HaystackBot marked this pull request as draft October 23, 2026 16:33
@CLAassistant

CLAassistant commented Oct 24, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@HaystackBot
HaystackBot marked this pull request as ready for review October 25, 2026 12:06
@HaystackBot
HaystackBot requested a review from anakin87 October 25, 2026 12:06
@HaystackBot HaystackBot removed the cla-pending PR is in draft until the contributor signs the CLA label Oct 25, 2026
@HaystackBot

Copy link
Copy Markdown
Contributor

Thanks for signing the CLA, @skulitom! 🎉 This PR is now ready for review again and the reviewer has been re-assigned.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/tools
  tool.py
Project Total  

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

@anakin87 anakin87 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution.

See #13411 (comment)

@anakin87

Copy link
Copy Markdown
Member

See #13411 (comment)

Thanks again

@anakin87 anakin87 closed this Oct 27, 2026
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.

Tool rejects inputs_from_state arguments accepted through **kwargs

4 participants