Replies: 1 comment
-
@JIeJaitt Best The most seemless way I found was to have the tool accept a So your tool can be modified to: from pydantic import BaseModel
from langchain_core.tools import tool
from langchain_core.runnables import RunnableConfig
class UserAuthStatusInput(BaseModel):
xxx: str
@tool(args_schema=UserAuthStatusInput)
def xxx_func(xxx: str, config: RunnableConfig) -> str:
thread_id = config.get("configurable", {}).get("thread_id")
print(f"[tool] thread_id={thread_id}")
return f"Echo: {xxx}" You would then inject this information when invoking the graph: config = {"configurable": {"thread_id": your_thread_id}}
result = graph.invoke({"messages": [("user", "hello")]}, config=config) Hope that helps! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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!
Beta Was this translation helpful? Give feedback.
All reactions