RunnableParallel.Get_input_schema Rejects Inputs That Invoke Accepts Due To Pydantic V2 Root Field Name Mismatch
RunnableParallel.get_input_schema merges step input schemas but fails to exclude the Pydantic v2 root model synthetic field 'root', causing the returned schema to reject every valid input that invoke accepts when any step is RunnablePassthrough or unannotated RunnableLambda.
In langchain_core/runnables/base.py, RunnableParallel.get_input_schema uses a list comprehension that excludes only the Pydantic v1 root field name '__root__' when merging step schemas. Pydantic v2 uses 'root' as the synthetic field name for root models (e.g., RootModel[int]), so the v2 field 'root' is incorrectly merged as a caller-supplied key. This creates a required 'root' field in the merged schema, making validation fail for any input without that key, while invoke treats the input as an ordinary dict.
# In langchain_core/runnables/base.py, within RunnableParallel.get_input_schema,
# replace the field_definitions comprehension with the following:
field_definitions={
k: _get_schema_field_definition(v)
for step in self.steps__.values()
for k, v in get_fields(step.get_input_schema(config)).items()
if k not in {"__root__", "root"}
}
The fix adds the Pydantic v2 root field name 'root' to the exclusion set alongside the legacy '__root__'. This prevents the synthetic root field from being merged into the parallel schema, resulting in a schema that correctly accepts any dict (or other input) that invoke accepts when at least one step is a passthrough or unannotated lambda. Existing schemas without such steps are unaffected.
Edge Case Audit
This change only affects the generated schema, not runtime invoke behavior. However, any downstream code that relied on the erroneous 'root' field in the schema (e.g., expecting validation to fail or passing {'root': ...}) may now behave differently. Rollback: revert the one-line change. Concurrency/threading not directly impacted, but if schema objects are cached across versions, upgrading from a buggy version to a fixed version may cause schema mismatch in long-running services; ensure all components are upgraded consistently.