Overview
LangChain’screate_agent runs on LangGraph’s runtime under the hood.
LangGraph exposes a Runtime object with the following information:
- Context: static information like user id, db connections, or other dependencies for an agent invocation
- Store: a BaseStore instance used for long-term memory
- Stream writer: an object used for streaming information via the
"custom"stream mode - Execution info: identity and retry information for the current execution (thread ID, run ID, attempt number)
- Server info: server-specific metadata when running on LangGraph Server (assistant ID, graph ID, authenticated user)
Access
When creating an agent withcreate_agent, you can specify a context_schema to define the structure of the context stored in the agent Runtime.
When invoking the agent, pass the context argument with the relevant configuration for the run:
Inside tools
You can access the runtime information inside tools to:- Access the context
- Read or write long-term memory
- Write to the custom stream (ex, tool progress / updates)
ToolRuntime parameter to access the Runtime object inside a tool.
Execution info and server info inside tools
Access execution identity (thread ID, run ID) viaruntime.execution_info, and server-specific metadata (assistant ID, authenticated user) via runtime.server_info when running on LangGraph Server:
server_info is None when not running on LangGraph Server (e.g., during local development).
Requires
deepagents>=0.5.0 (or langgraph>=1.1.5) for runtime.execution_info and runtime.server_info.Inside middleware
You can access runtime information in middleware to create dynamic prompts, modify messages, or control agent behavior based on user context. Use theRuntime parameter to access the Runtime object inside node-style hooks. For wrap-style hooks, the Runtime object is available inside the ModelRequest parameter.
Execution info and server info inside middleware
Middleware hooks can also accessruntime.execution_info and runtime.server_info:
Requires
deepagents>=0.5.0 (or langgraph>=1.1.5).Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

