How LangChain v1 Protects User Identity Data During Agent Tool Execution
LangChain v1 introduces ToolRuntime to pass authenticated user IDs to tools via agent state without exposing sensitive parameters to the LLM.

In modern AI applications, agents function by executing language models inside a continuous processing loop. Within this loop, the model inspects incoming chat conversations, determines whether an external tool should be invoked, processes the tool's return values, and formulates a final response to the user. As part of this decision-making cycle, the model is also tasked with picking the specific tool to execute and defining the precise arguments that will be passed into it. While this dynamic flow works seamlessly when handling public or non-sensitive data, it introduces significant technical and security challenges when a tool requires specific details bound to an individual user.
The security gap in agentic tool calling
Many real-world software tools depend heavily on user-specific parameters to function correctly. For instance, services designed to look up bank account balances, check order fulfillment statuses, or retrieve employee leave records must know exactly which user's profile to query. Under standard tool-calling design patterns, if a function requires an explicit argument like a user identifier parameter, the underlying language model is forced to generate that value.
Because the model only possesses visibility into the active chat session context, it must rely on limited options to fulfill the required input. The model might directly ask the end user to state their user ID, attempt to guess the value, or pick up an identifier provided within the chat prompt. In production applications where a system has already authenticated the user upon login, relying on the model to handle user identification is problematic. Giving the model responsibility over user identifiers creates severe security vulnerabilities, as malicious or mistaken chat inputs could allow standard prompts to supply arbitrary IDs or cause the system to process incorrect account records.
How LangChain v1 addresses user data privacy
To address this risk, LangChain v1 introduces a structural mechanism called ToolRuntime. This feature allows a tool function to explicitly declare runtime parameters that are automatically populated at execution time using the agent's internal state, store, context, and other system-level runtime details.
Crucially, any runtime parameter configured through ToolRuntime is completely omitted from the tool description and schema that LangChain transmits to the language model. Because the parameter is invisible to the model, the LLM cannot see, modify, or attempt to generate its value. Instead, the application passes authenticated system data directly into the tool function when execution occurs, bypassing the LLM entirely.
Consider a practical example involving a banking application support assistant. When an authenticated customer named Priya opens the chat interface, the application backend already verifies her session and holds her true user ID. When she asks the assistant to check her account details, the tool receives her verified user ID directly through the system state rather than relying on the LLM to supply it. Developers testing complex tool integrations across different LLM backends can try top AI models cheaply through one API at https://apixoai.online to evaluate performance while keeping sensitive identity parameters isolated.
What it means for developers
For software engineers building production-ready AI agents, the implementation of runtime parameters shifts how sensitive context is handled across tool executions. By keeping user identity parameters out of model schemas, applications prevent prompt injection attacks or hallucinations from compromising user data boundaries.
Developers no longer need to write complex prompt instructions telling the model not to ask for user IDs or build fragile parsing logic to validate LLM-generated identity tokens. Instead, authentication data remains safely isolated in system memory and runtime context. This separation ensures that language models are limited strictly to reasoning and tool selection, while the application framework guarantees that data retrieval functions execute strictly within the security context of the authenticated user.
Source: Protecting User Data in LangChain — Towards AI. Written by the Apixo team from that report.
One key for Claude, GPT, GLM, DeepSeek and more. Pay per token with crypto.
Get your API key

