You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ComponentTool executes dataclass default factories during schema generation #13689
Constructing ComponentTool executes dataclass default_factory functions while generating the JSON schema. Merely describing a component can therefore consume IDs or perform setup intended for a real invocation. A factory whose runtime resource is not ready prevents tool construction, even when callers would supply the field explicitly.
_dataclass_to_pydantic_model calls field.default_factory() and stores the resulting value as a static Pydantic default. Keeping it as Field(default_factory=...) would describe the optional field without executing the factory.
Schema construction should not run dataclass factories. Omitted values should be generated per invocation; explicit values should not run the factory. Schema generation should not advertise a concrete default that was created during setup.
Additional context
Reproduced through the real public component/tool APIs using Hatch, with no model/provider or external-service fixture. Three new regression cases fail on the original source, while two existing dataclass controls pass. Existing #13516 handles string annotations in the same helper and retains the factory call; this is a separate behavior defect. Preparing a focused fix and regression tests.
AI assistance: OpenAI Codex performed the investigation and local reproduction. No production incident or personal testing by the account owner is claimed.
System:
OS: macOS, Python 3.12.13
Haystack version: 3.6.0-rc0, main 3a753721265dc167bc908b947d7d33e7fead76f5
Activity