Repository navigation
fix(tools): keep dataclass default factories lazy - #13690
Open
Elon-Jiang wants to merge 1 commit into
Open
Elon-Jiang wants to merge 1 commit into
Elon-Jiang wants to merge 1 commit into
Conversation
Co-authored-by: OpenAI Codex <[email protected]>
Elon-Jiang
requested review from
bogdankostic
and removed request for
a team
November 11, 2026 12:59
Contributor
|
@Elon-Jiang is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Hi @Elon-Jiang, thanks a lot for your contribution! 🙏 We noticed that the Contributor License Agreement (CLA) check ( To get your PR reviewed, please sign the CLA via the link in the |
HaystackBot
marked this pull request as draft
November 11, 2026 14:22
HaystackBot
marked this pull request as ready for review
November 12, 2026 02:07
Contributor
|
Thanks for signing the CLA, @Elon-Jiang! 🎉 This PR is now ready for review again and the reviewer has been re-assigned. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Fixes #13689.
Proposed Changes:
ComponentToolexecutes dataclassdefault_factoryfunctions while constructing parameter schemas. A counting factory is called once before any invocation, so the first real invocation receives the second generated value. A factory that depends on an unavailable runtime resource prevents tool construction even when the caller would supply the field explicitly.Preserve the callable as a Pydantic
Field(default_factory=...)instead of executing it during schema conversion. Factory-backed fields stay optional and no longer advertise a captured concretedefault; explicit static defaults are unchanged. Update the existing schema expectations, public documentation and release note to describe this visible schema change.How did you test it?
Python 3.12.13, Hatch 1.18.2, Haystack 3.6.0-rc0, baseline
3a753721265dc167bc908b947d7d33e7fead76f5:ComponentToolreproduction: baseline constructs with one factory call and returns token2on first invocation; patched construction makes zero calls and first invocation returns token1. Providing an explicit token does not run the factory.hatch run test:unit test/tools test/core/test_type_utils.py test/core/component test/components/agents -q --no-cov: 1828 passed, 2 skipped, 18 deselected (3 warnings).hatch run test:typeson the four changed Python files: no issues.hatch run fmtand all applicablepre-commit run --files ...hooks passed, including Ruff, codespell, release-note checks and syntax/YAML checks.hatch build -t wheelpassed;git diff --checkpassed.Tests execute actual dataclass construction, schema generation and public tool invocation; no external model, service or replacement implementation is involved. Live-provider integration tests and the entire documentation website build were not run.
Notes for the reviewer
The nearby #13516 fixes postponed dataclass annotations and leaves the eager factory call in place; it addresses a separate defect. This patch keeps the change local to default handling and can be rebased if that annotation change lands first.
This PR was fully generated with OpenAI Codex. Codex reviewed the diff and ran the recorded checks; this does not assert personal code review or testing by the account owner.
Checklist