IVQ 151-200
Security, Compliance & Governance
How do you handle authentication/authorization?
Wrap LangGraph in an API server (FastAPI).
Add JWT/OAuth for user auth.
Verify user scopes/roles before running
graph.run().
Restrict access to specific nodes or state variables?
Not native — handle with node-level checks:
def sensitive_node(state, user): if not user.is_admin: raise PermissionError()Or split into separate graphs with different endpoints.
Ensure compliance (GDPR, HIPAA)?
Minimize PII in state.
Encrypt state at rest.
Log access for audit.
Provide deletion hooks for GDPR Right to Erasure.
Sanitize/redact sensitive data?
Use a
redact_nodeto mask PII before logging or output.Apply regex or DLP tools inside nodes.
155. Sign or verify workflows?
Not built-in. Use:
Signed containers/images.
Signed config manifests.
Hash workflow code & verify at deploy.
156. Audit data access?
Log every state read/write with user ID and timestamp.
Store immutable logs (e.g., append-only S3 or DB).
RBAC for triggering workflows?
Enforce RBAC at API layer.
Map roles to allowed workflows/nodes.
Vault-based secret management?
Use
vaultor AWS Secrets Manager.Inject secrets at node runtime (not hardcoded).
159. Logging best practices for compliance?
Don’t log raw PII.
Anonymize tokens.
Use structured, timestamped logs.
Centralize logs in secure storage.
160. Encrypt state + outputs?
At rest: encrypt DB/S3.
In transit: HTTPS/TLS for API calls.
Optionally encrypt parts of
statepayloads.
Performance & Optimization
161. Profile for bottlenecks?
Time each node (decorators).
Log duration to Prometheus.
162. Overhead vs raw Python?
Minor — the main cost is the extra orchestration logic, which is minimal.
95% of cost = LLM calls anyway.
163. Limit API/token usage?
Track
usagefrom LLM API.Abort flow if tokens exceed limit.
Enforce quota per user in
state.
Caching?
Use Redis or DB.
Cache LLM results by prompt hash.
Manage compute-intensive ops?
Offload to async workers.
Run heavy nodes on GPU pods.
Backpressure/rate-limiting?
Throttle node calls.
Use API rate limit headers.
Back off + retry on 429s.
Checkpoint/resume?
Persist
stateto DB after each node.Resume from last good state.
Reduce latency multi-hop?
Minimize hops when possible.
Use streaming LLM calls.
Batch prompts.
Batch node executions?
Some nodes can handle batch inputs:
E.g., embedding 10 docs at once.
170. Parallelize retrieval + reasoning?
Use async nodes: gather retrieval tasks, then LLM.
Or multi-graph runs in parallel containers.
Generative AI & LLM-Specific Workflows
Design a RAG pipeline?
Node1: Embed query → Node2: Vector search → Node3: LLM combines query + context.
Orchestrate summarization + Q&A?
Node1: Summarize → Node2: Generate Qs → Node3: Answer Qs → Output.
Switch LLMs mid-workflow?
Use config in
state:
174. Add guardrails?
Use moderation APIs or regex to filter LLM output.
Add rejection loops if content is unsafe.
175. Dynamic prompt templates?
Store in config files or DB.
Render with Jinja or f-strings per state.
Multi-modal input?
Nodes can call image or speech APIs → output goes to LLM node.
Complex tool-using agents?
Model as: Planner node → Conditional edge → Tool nodes → Loop back.
Token-level logging?
Log
usagefrom LLM API.Store prompt/response + token counts.
179. Combine with embeddings?
Embed inside node → call Qdrant → feed context to next LLM node.
A/B test LLM behavior?
Conditional edges: branch to
LLM_AvsLLM_B.Store results for comparison.
Multi-Agent & Conversational Reasoning
Define agents as nodes?
Each agent = node or cluster of nodes.
Multiple agents exchange memory?
stateholds shared memory → pass across nodes.
Model plan → exec → eval?
Node1: Planner → Node2: Executor → Node3: Evaluator → loop.
Turn-based conversation?
historyin state.LLM node generates next turn.
Decentralized agent behavior?
Multiple sub-graphs communicate via shared
state.
Assign agent roles?
Store
agent_roleinstate.Nodes act differently by role.
Share global context?
Same
stateor shared DB.
Resolve agent conflicts?
Add resolution node: merge, vote, or escalate.
Controller for agent swarm?
LangGraph = central controller for multi-agent graph.
Simulate user-agent loop?
Use test nodes with canned inputs to simulate user replies.
Deployment, Edge, Future Strategy
Edge or browser deploy?
Not practical for full graph — too heavy.
But tiny graphs with local models? Possible.
Limitations offline?
Needs LLM inference server or local model.
Otherwise no generation.
Deploy via serverless?
Wrap as Lambda/FastAPI → stateless short runs only.
Integrate with private LLM infra?
Just point LLM calls to your private API endpoint.
Control robotics/physical agents?
Yes — nodes can issue actuator commands, same as any tool node.
Evolve to vision/audio?
Add multi-modal nodes: call image/audio models → feed outputs to LLM.
Event-based workflows?
Add event listeners → trigger graph runs on events.
Or integrate with Kafka/webhooks.
Orchestrate distributed AI microservices?
Use LangGraph as control layer → delegate work to microservices.
Roadmap for plugins/tools?
Community is building:
Common node libs.
Visualizers.
Tool executor templates.
Future-proof for model APIs?
Keep LLM calls modular.
Parametrize
model_name/api_urlin config/state.
Last updated