[Python] How to retrieve the current conversation ID inside a tool function in LangGraph?

Discussão em 'Python' iniciado por Stack, Setembro 4, 2025.

  1. Stack

    Stack Membro Participativo

    Is there any built-in way for a LangGraph tool function to access the current conversation (session/thread) ID at runtime? I need this ID for logging and external service correlation, but I can’t find it in the function signature or documentation. Any guidance would be appreciated—thanks!

    from langchain_core.tools import tool
    from pydantic import BaseModel

    class UserAuthStatusInput(BaseModel):
    xxx: str

    @tool(args_schema=UserAuthStatusInput)
    def xxx_func(xxx: str) -\> str:
    \# business logic here...
    \# TODO: how to retrieve the current conversation/thread ID at this point?
    return "some result"


    langGraph docs shortcut

    Related discussion: https://github.com/langchain-ai/langgraph/discussions/6076

    Continue reading...

Compartilhe esta Página