Skip to content

Conversation

@aran-yogesh
Copy link

Resolves #33726

  • Add get_config() function to access RunnableConfig in middleware hooks
  • Enable context-aware middleware based on metadata, tags, and config
  • Add comprehensive test suite with 9 unit tests
  • Update documentation with usage examples
  • Maintain full backward compatibility

This allows middleware to implement user-specific behavior, conditional logging, audit trails, and environment-specific processing based on the RunnableConfig passed to agent.invoke().

(Replace this entire block of text)

Thank you for contributing to LangChain! Follow these steps to mark your pull request as ready for review. If any of these steps are not completed, your PR will not be considered for review.

  • PR title: Follows the format: {TYPE}({SCOPE}): {DESCRIPTION}

    • Examples:
      • feat(core): add multi-tenant support
      • fix(cli): resolve flag parsing error
      • docs(openai): update API usage examples
    • Allowed {TYPE} values:
      • feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert, release
    • Allowed {SCOPE} values (optional):
      • core, cli, langchain, standard-tests, text-splitters, docs, anthropic, chroma, deepseek, exa, fireworks, groq, huggingface, mistralai, nomic, ollama, openai, perplexity, prompty, qdrant, xai, infra
    • Once you've written the title, please delete this checklist item; do not include it in the PR.
  • PR message: Delete this entire checklist and replace with

  • Lint and test: Run make format, make lint and make test from the root of the package(s) you've modified. We will not consider a PR unless these three are passing in CI. See contribution guidelines for more.

Additional guidelines:

  • Most PRs should not touch more than one package.
  • Please do not add dependencies to pyproject.toml files (even optional ones) unless they are required for unit tests. Likewise, please do not update the uv.lock files unless you are adding a required dependency.
  • Changes should be backwards compatible.
  • Make sure optional dependencies are imported within a function.

Resolves langchain-ai#33726

- Add get_config() function to access RunnableConfig in middleware hooks
- Enable context-aware middleware based on metadata, tags, and config
- Add comprehensive test suite with 9 unit tests
- Update documentation with usage examples
- Maintain full backward compatibility

This allows middleware to implement user-specific behavior, conditional
logging, audit trails, and environment-specific processing based on the
RunnableConfig passed to agent.invoke().
@github-actions github-actions bot added langchain Related to the package `langchain` v1 Issue specific to LangChain 1.0 feature labels Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature langchain Related to the package `langchain` v1 Issue specific to LangChain 1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add RunnableConfig Access in Agent Middleware Functions

1 participant