Skip to content

LangGraph Plugin: Session

The FlotorchLanggraphSession provides comprehensive session management for LangGraph agents, enabling persistent storage of conversation history and agent state through FloTorch Gateway. It implements LangGraph’s BaseCheckpointSaver interface and stores conversation history as FloTorch session events, enabling persistent state management across agent interactions.

Before using FlotorchLanggraphSession, ensure you have completed the general prerequisites outlined in the LangGraph Plugin Overview, including installation and environment configuration.

Configure your session service with the following parameters:

FlotorchLanggraphSession(
api_key: str, # FloTorch API key for authentication (required)
base_url: str, # FloTorch Gateway endpoint URL (required)
app_name: str, # Application name for session identification (required)
user_id: str # User identifier for session identification (required)
)

Parameter Details:

  • api_key - Authentication key for accessing FloTorch Gateway (can be set via environment variable)
  • base_url - The FloTorch Gateway endpoint URL (can be set via environment variable)
  • app_name - Application name for identifying sessions
  • user_id - User identifier for isolating sessions per user

Fully implements LangGraph’s BaseCheckpointSaver interface:

  • Checkpoint Operations - Supports checkpoint save and load operations
  • State Persistence - Persists agent state and conversation history
  • LangGraph Compatibility - Works seamlessly with LangGraph’s checkpoint framework

Provides comprehensive session persistence capabilities:

  • Gateway Storage - Stores session data persistently in FloTorch Gateway
  • Event History - Preserves complete event history across service restarts
  • State Synchronization - Automatically synchronizes state management
  • Format Conversion - Seamlessly converts events between LangGraph and FloTorch formats

Manages conversation threads for LangGraph agents:

  • Thread Identification - Uses thread_id in config for thread identification
  • State Management - Manages state per thread automatically
  • Conversation Continuity - Maintains conversation continuity across interactions
from flotorch.langgraph.agent import FlotorchLangGraphAgent
from flotorch.langgraph.sessions import FlotorchLanggraphSession
# Initialize session service
checkpointer = FlotorchLanggraphSession(
api_key="your_api_key",
base_url="https://gateway.flotorch.cloud",
app_name="your_app",
user_id="user_123"
)
# Use with agent
agent_manager = FlotorchLangGraphAgent(
agent_name="customer-support",
checkpointer=checkpointer, # Add checkpointer
base_url="https://gateway.flotorch.cloud",
api_key="your_api_key"
)
agent = agent_manager.get_agent()
# Use with config for session persistence
config = {"configurable": {"thread_id": "your_thread_id"}}
response = agent.invoke({"messages": user_input}, config)
from flotorch.langgraph.sessions import FlotorchLanggraphSession
# Initialize session service
checkpointer = FlotorchLanggraphSession(
api_key="your_api_key",
base_url="https://gateway.flotorch.cloud",
app_name="your_app",
user_id="user_123"
)
# Use with LangGraph agent
from langgraph.prebuilt import create_react_agent
agent = create_react_agent(
model=model,
tools=tools,
checkpointer=checkpointer
)
# Use with config for session persistence
config = {"configurable": {"thread_id": "unique_thread_id"}}
response = agent.invoke({"messages": user_input}, config)
  1. Environment Variables - Use environment variables for credentials to enhance security
  2. Session Management - Implement proper session lifecycle management for long-running applications
  3. Thread Identification - Use unique thread_id values to prevent conflicts between different conversations
  4. Error Handling - Implement robust error handling for network and storage operations
  5. Session Cleanup - Consider implementing session cleanup strategies for production environments