Skip to content

Conversation

raviraj-441
Copy link
Contributor

Issue

Fixes #32671

Summary

  • Ensure AgentExecutor propagates RunnableConfig to tools in both sync (invoke/_call) and async (ainvoke/_acall) paths.
  • Support tools that accept Optional[RunnableConfig] or Union[RunnableConfig, None] in their signatures.
  • Maintain return_direct behavior, async handling with asyncio_timeout, and trimming of intermediate steps.

Implementation notes

  • AgentExecutor sets/restores a private current config around invoke/ainvoke using a module-level sentinel and restores it safely (mypy clean).
  • Tools receive the config via getattr(self, "_current_config", None) and are invoked with it when present.
  • yaml import marked untyped to satisfy mypy; can switch to types-PyYAML if preferred.

Tests

  • Added tests cover Optional[RunnableConfig] and Union[RunnableConfig, None] in sync and async tool paths.
  • Verified return_direct, async timeout behavior, and intermediate step trimming.
  • Core JSON schema recursion tests also pass locally.

Checklist

  • No public API changes.
  • Full type hints and docs preserved.
  • Unit tests added and passing.
  • Lint/format and mypy clean for changed files.

…tional/union typing coverage\n test(core): add JSON schema dereference recursion guards\n chore(scripts): move manual validation under scripts/manual and remove root-level copies
…(sync/async); support Optional/Union signatures; mypy and lint clean
@raviraj-441 raviraj-441 requested a review from eyurtsev as a code owner August 31, 2025 15:08
Copy link

vercel bot commented Aug 31, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
langchain Ignored Ignored Preview Sep 8, 2025 5:33pm

Copy link

codspeed-hq bot commented Aug 31, 2025

CodSpeed WallTime Performance Report

Merging #32768 will not alter performance

Comparing raviraj-441:fix/agents-config-propagation (1405fca) with master (01fdeed)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 13 untouched benchmarks

@raviraj-441 raviraj-441 changed the title fix(agents): propagate RunnableConfig to tools in AgentExecutor (sync/async); support Optional/Union signatures fix(core): propagate RunnableConfig to tools in AgentExecutor (sync/async); support Optional/Union signatures Aug 31, 2025
Copy link

codspeed-hq bot commented Aug 31, 2025

CodSpeed Instrumentation Performance Report

Merging #32768 will not alter performance

Comparing raviraj-441:fix/agents-config-propagation (1405fca) with master (01fdeed)

Summary

✅ 14 untouched benchmarks

@mdrxy mdrxy changed the title fix(core): propagate RunnableConfig to tools in AgentExecutor (sync/async); support Optional/Union signatures fix(core): propagate RunnableConfig to tools in AgentExecutor (sync/async); support Optional/Union signatures Aug 31, 2025
@mdrxy mdrxy added core Related to the package `langchain-core` langchain Related to the package `langchain` labels Aug 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to the package `langchain-core` langchain Related to the package `langchain`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Config not passed to tools when using AgentExecutor
2 participants