How to Integrate LangGraph for fintech with Redis for AI agents
LangGraph gives you the control flow for multi-step agent systems. Redis gives you fast state, caching, and shared memory across requests and workers. Put them together and you can build fintech agents that keep conversation state, persist risk checks, and resume workflows after a timeout or service restart.
Prerequisites
- •Python 3.10+
- •A Redis instance running locally or in your cloud environment
- •A LangGraph-based agent project already created
- •Installed packages:
- •
langgraph - •
langchain-core - •
redis - •
python-dotenvif you want environment-based config
- •
- •A Redis URL such as:
- •
redis://localhost:6379/0 - •or a managed Redis endpoint from AWS ElastiCache, Azure Cache for Redis, or Upstash
- •
- •Basic understanding of:
- •LangGraph state graphs
- •Python async/sync execution
- •Fintech workflows like KYC, fraud review, payment approval, or claims triage
Integration Steps
- •
Install the dependencies
Start by installing the core packages. For production fintech systems, pin versions in
requirements.txtso graph behavior and Redis client behavior stay stable.pip install langgraph langchain-core redis python-dotenv - •
Create a Redis-backed checkpoint store
LangGraph supports checkpointing so your agent can resume from prior state. For fintech workflows, that matters when a user drops off mid-flow or when an approval chain spans multiple services.
import os from redis import Redis redis_client = Redis.from_url( os.getenv("REDIS_URL", "redis://localhost:6379/0"), decode_responses=True, ) # Simple connectivity check print(redis_client.ping())In production, use this Redis client for shared state like session metadata, fraud flags, or step completion markers.
- •
Define your LangGraph state and nodes
Here’s a minimal graph for a fintech agent that receives a transaction request, stores it in Redis, then routes to review logic.
from typing import TypedDict, Optional from langgraph.graph import StateGraph, START, END class AgentState(TypedDict): user_id: str transaction_id: str amount: float risk_score: Optional[float] decision: Optional[str] def persist_request(state: AgentState): redis_client.hset( f"txn:{state['transaction_id']}", mapping={ "user_id": state["user_id"], "amount": str(state["amount"]), "status": "received", }, ) return state def assess_risk(state: AgentState): amount = state["amount"] risk_score = 0.9 if amount > 10000 else 0.2 return {"risk_score": risk_score} def decide(state: AgentState): decision = "manual_review" if state["risk_score"] and state["risk_score"] > 0.7 else "approve" redis_client.hset( f"txn:{state['transaction_id']}", mapping={"risk_score": str(state["risk_score"]), "decision": decision}, ) return {"decision": decision} - •
Wire the graph together with LangGraph APIs
Use
StateGraph,add_node,add_edge, andcompile()to create the workflow. This is the part most teams get wrong: keep business decisions in nodes and persistence outside the model call path where possible.workflow = StateGraph(AgentState) workflow.add_node("persist_request", persist_request) workflow.add_node("assess_risk", assess_risk) workflow.add_node("decide", decide) workflow.add_edge(START, "persist_request") workflow.add_edge("persist_request", "assess_risk") workflow.add_edge("assess_risk", "decide") workflow.add_edge("decide", END) app = workflow.compile() - •
Run the agent and persist execution context in Redis
In fintech systems you usually want an execution key per user session or transaction ID. That lets you replay decisions, inspect failures, and continue processing later.
initial_state = { "user_id": "u_12345", "transaction_id": "tx_98765", "amount": 12500.0, "risk_score": None, "decision": None, } result = app.invoke(initial_state) print(result) print(redis_client.hgetall("txn:tx_98765"))
Testing the Integration
Use a direct invocation test to confirm both LangGraph execution and Redis persistence work as expected.
test_state = {
"user_id": "u_test",
"transaction_id": "tx_test_001",
"amount": 2500.0,
"risk_score": None,
"decision": None,
}
result = app.invoke(test_state)
stored = redis_client.hgetall("txn:tx_test_001")
print("GRAPH RESULT:", result)
print("REDIS STATE:", stored)
Expected output:
GRAPH RESULT: {'user_id': 'u_test', 'transaction_id': 'tx_test_001', 'amount': 2500.0, 'risk_score': 0.2, 'decision': 'approve'}
REDIS STATE: {'user_id': 'u_test', 'amount': '2500.0', 'status': 'received', 'risk_score': '0.2', 'decision': 'approve'}
If you see both outputs match, your agent can execute deterministic steps in LangGraph while persisting operational data in Redis.
Real-World Use Cases
- •
Payment authorization agents
- •Route high-value transfers to manual review.
- •Store transaction checkpoints in Redis so ops teams can resume processing after escalation.
- •
KYC and onboarding workflows
- •Track document upload status, verification results, and retry counts.
- •Use Redis to cache identity lookups and reduce repeated external API calls.
- •
Claims or dispute triage
- •Keep case state across multiple tool calls.
- •Use LangGraph for branching logic and Redis for shared case memory across workers.
Keep learning
- •The complete AI Agents Roadmap — my full 8-step breakdown
- •Free: The AI Agent Starter Kit — PDF checklist + starter code
- •Work with me — I build AI for banks and insurance companies
By Cyprian Aarons, AI Consultant at Topiax.
Want the complete 8-step roadmap?
Grab the free AI Agent Starter Kit — architecture templates, compliance checklists, and a 7-email deep-dive course.
Get the Starter Kit