I use the injected state approach to pass state to a tool. But I want to inject a subset of my state into a langgraph tool and not the entire keys. e.g. there is a variable/key called user_name. I want to pass that and not the messages etc. Is it possible to do so? Note that using a plain argument will not work since this will be acting like a shared variable
Hey @mgathena yes you can pass a key via injected state by doing something like:
@tool
def get_user_greeting(
message: str,
user_name: Annotated[str, InjectedState("user_name")]
) -> str:
"""Generate a personalized greeting."""
return f"Hello {user_name}! {message}"
Awesome. Thanks. will definitely try this out.