- Notifications
You must be signed in to change notification settings - Fork20.1k
fix(core): populate default args from tool's args_schema#34399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
fix(core): populate default args from tool's args_schema#34399
Conversation
When a tool has an args_schema with Pydantic default values (e.g.,`page: int = Field(default=1, ...)`), those defaults are now passedto the tool function when the caller omits optional arguments.Previously, the `_parse_input` method filtered validated results toonly include keys that were in the original input, discarding Pydanticdefaults. Now it includes fields with non-None defaults, which appliesuser-defined defaults while excluding synthetic fields from *args/*kwargs.Fixeslangchain-ai#34384
a70d266 to2fec706CompareCodSpeed Performance ReportMerging#34399 willimprove performances by 33.42%Comparing
|
| Mode | Benchmark | BASE | HEAD | Change | |
|---|---|---|---|---|---|
| ⚡ | WallTime | test_import_time[InMemoryVectorStore] | 646.5 ms | 554.2 ms | +16.65% |
| ⚡ | WallTime | test_import_time[InMemoryRateLimiter] | 188.6 ms | 159.7 ms | +18.12% |
| ⚡ | WallTime | test_import_time[Document] | 195.7 ms | 169.3 ms | +15.55% |
| ⚡ | WallTime | test_import_time[HumanMessage] | 281 ms | 244.7 ms | +14.87% |
| ⚡ | WallTime | test_import_time[LangChainTracer] | 479.2 ms | 397.7 ms | +20.48% |
| ⚡ | WallTime | test_async_callbacks_in_sync | 25.3 ms | 19 ms | +33.42% |
| ⚡ | WallTime | test_import_time[RunnableLambda] | 544.2 ms | 447.8 ms | +21.51% |
| ⚡ | WallTime | test_import_time[tool] | 542.8 ms | 477.4 ms | +13.72% |
| ⚡ | WallTime | test_import_time[ChatPromptTemplate] | 629.4 ms | 535.8 ms | +17.48% |
| ⚡ | WallTime | test_import_time[BaseChatModel] | 550.9 ms | 489.1 ms | +12.64% |
| ⚡ | WallTime | test_import_time[CallbackManager] | 485.3 ms | 430.6 ms | +12.71% |
| ⚡ | WallTime | test_import_time[PydanticOutputParser] | 575.1 ms | 475.4 ms | +20.98% |
| ⚡ | WallTime | test_import_time[Runnable] | 525 ms | 466.8 ms | +12.48% |
Footnotes
21 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase,click here and archive them to remove them from the performance reports.↩
nathannewyen commentedDec 17, 2025
The CI failure in The test fails because Could a maintainer please re-run the CI or mark this as a known flaky test? |
Uh oh!
There was an error while loading.Please reload this page.
Summary
args_schemawere not passed to tool functions when the caller omits optional arguments_parse_input()inlibs/core/langchain_core/tools/base.pyto include fields with non-None defaultsProblem
When a tool has an
args_schemawith default values:The defaults from
args_schemawere being discarded because_parse_input()filtered validated results to only include keys from the original input.Solution
Changed the filtering logic to:
This applies user-defined defaults (like
Field(default=1)) while excluding synthetic fields from*args/**kwargswhich havedefault=None.Test plan
test_tool_args_schema_default_values- tests sync tool with defaultstest_tool_args_schema_default_values_async- tests async tool with defaultsFixes#34384