IVQ 151-200

Security, Compliance & Governance

  1. 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().


  1. 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.


  1. Ensure compliance (GDPR, HIPAA)?

  • Minimize PII in state.

  • Encrypt state at rest.

  • Log access for audit.

  • Provide deletion hooks for GDPR Right to Erasure.


  1. Sanitize/redact sensitive data?

  • Use a redact_node to 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).


  1. RBAC for triggering workflows?

  • Enforce RBAC at API layer.

  • Map roles to allowed workflows/nodes.


  1. Vault-based secret management?

  • Use vault or 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 state payloads.


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 usage from LLM API.

  • Abort flow if tokens exceed limit.

  • Enforce quota per user in state.


  1. Caching?

  • Use Redis or DB.

  • Cache LLM results by prompt hash.


  1. Manage compute-intensive ops?

  • Offload to async workers.

  • Run heavy nodes on GPU pods.


  1. Backpressure/rate-limiting?

  • Throttle node calls.

  • Use API rate limit headers.

  • Back off + retry on 429s.


  1. Checkpoint/resume?

  • Persist state to DB after each node.

  • Resume from last good state.


  1. Reduce latency multi-hop?

  • Minimize hops when possible.

  • Use streaming LLM calls.

  • Batch prompts.


  1. 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

  1. Design a RAG pipeline?

  • Node1: Embed query → Node2: Vector search → Node3: LLM combines query + context.


  1. Orchestrate summarization + Q&A?

  • Node1: Summarize → Node2: Generate Qs → Node3: Answer Qs → Output.


  1. 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.


  1. Multi-modal input?

  • Nodes can call image or speech APIs → output goes to LLM node.


  1. Complex tool-using agents?

  • Model as: Planner node → Conditional edge → Tool nodes → Loop back.


  1. Token-level logging?

  • Log usage from LLM API.

  • Store prompt/response + token counts.


179. Combine with embeddings?

  • Embed inside node → call Qdrant → feed context to next LLM node.


  1. A/B test LLM behavior?

  • Conditional edges: branch to LLM_A vs LLM_B.

  • Store results for comparison.


Multi-Agent & Conversational Reasoning

  1. Define agents as nodes?

  • Each agent = node or cluster of nodes.


  1. Multiple agents exchange memory?

  • state holds shared memory → pass across nodes.


  1. Model plan → exec → eval?

  • Node1: Planner → Node2: Executor → Node3: Evaluator → loop.


  1. Turn-based conversation?

  • history in state.

  • LLM node generates next turn.


  1. Decentralized agent behavior?

  • Multiple sub-graphs communicate via shared state.


  1. Assign agent roles?

  • Store agent_role in state.

  • Nodes act differently by role.


  1. Share global context?

  • Same state or shared DB.


  1. Resolve agent conflicts?

  • Add resolution node: merge, vote, or escalate.


  1. Controller for agent swarm?

  • LangGraph = central controller for multi-agent graph.


  1. Simulate user-agent loop?

  • Use test nodes with canned inputs to simulate user replies.


Deployment, Edge, Future Strategy

  1. Edge or browser deploy?

  • Not practical for full graph — too heavy.

  • But tiny graphs with local models? Possible.


  1. Limitations offline?

  • Needs LLM inference server or local model.

  • Otherwise no generation.


  1. Deploy via serverless?

  • Wrap as Lambda/FastAPI → stateless short runs only.


  1. Integrate with private LLM infra?

  • Just point LLM calls to your private API endpoint.


  1. Control robotics/physical agents?

  • Yes — nodes can issue actuator commands, same as any tool node.


  1. Evolve to vision/audio?

  • Add multi-modal nodes: call image/audio models → feed outputs to LLM.


  1. Event-based workflows?

  • Add event listeners → trigger graph runs on events.

  • Or integrate with Kafka/webhooks.


  1. Orchestrate distributed AI microservices?

  • Use LangGraph as control layer → delegate work to microservices.


  1. Roadmap for plugins/tools?

  • Community is building:

    • Common node libs.

    • Visualizers.

    • Tool executor templates.


  1. Future-proof for model APIs?

  • Keep LLM calls modular.

  • Parametrize model_name/api_url in config/state.


Last updated