---
title: "From Rigid Rules to Empathetic Agents: Rebuilding Swiggy’s Order Cancellation Experience with LLMs"
description: "Swiggy rebuilt its “I Want To Cancel” (IWTC) support journey because a roughly 150K-line deterministic decision tree treated cancellation keywords alike, repeated canned deterrence, and could leave users stuck without handoff. The replacement is a stateful, multi-turn framework orchestrated with LangGraph: an intent layer identifies needs such as delay help, coupon support, direct cancellation, or human access, while live order signals and deterministic policy checks determine the next action. Full graph state is checkpointed in Redis by order- and session-level thread IDs, allowing conversations to resume across turns. Swiggy evaluated intent reliability using more than 100k historical chats and a pre-deployment suite of about 500 representative queries, then operated the system with reporting and alerts for behavioral and service metrics. The conclusion favors a hybrid design in which LLMs handle language while deterministic systems anchor truth and business decisions."
---

# From Rigid Rules to Empathetic Agents: Rebuilding Swiggy’s Order Cancellation Experience with LLMs

[Swiggy](https://yomu.fyi/company/swiggy) · Aishwary Yadav · May 29, 2026

**Type:** Problem & solution

## Summary

Swiggy rebuilt its “I Want To Cancel” (IWTC) support journey because a roughly 150K-line deterministic decision tree treated cancellation keywords alike, repeated canned deterrence, and could leave users stuck without handoff. The replacement is a stateful, multi-turn framework orchestrated with LangGraph: an intent layer identifies needs such as delay help, coupon support, direct cancellation, or human access, while live order signals and deterministic policy checks determine the next action. Full graph state is checkpointed in Redis by order- and session-level thread IDs, allowing conversations to resume across turns. Swiggy evaluated intent reliability using more than 100k historical chats and a pre-deployment suite of about 500 representative queries, then operated the system with reporting and alerts for behavioral and service metrics. The conclusion favors a hybrid design in which LLMs handle language while deterministic systems anchor truth and business decisions.

## Context

The legacy IWTC bot was a deterministic decision tree of roughly 150K lines. It matched cancellation-related input to rigid paths, repeated fixed deterrence messages, could force users toward cancellation when they needed information or assistance, and lacked a graceful handoff when it could not resolve an issue. Its growing coupling also made new scenarios, rules, debugging, and maintenance harder.

## Approach / What changed

IWTC was rebuilt as a stateful, multi-turn LLM system orchestrated with LangGraph. An intent layer identifies the customer’s underlying need, backend services provide live order signals, and deterministic policy checks choose whether to assist, resolve, provide service recovery, or hand off to a human. LangGraph state is persisted in Redis, while LLMs generate language and deterministic systems provide operational truth and enforce business decisions.

## Takeaways

- The new flow separates language understanding from operational decisions: the LLM classifies intent and generates responses, while backend services and deterministic policy checks determine what is true and what action should follow.
- The full LangGraph conversation state is serialized to Redis after each node execution and keyed by an order- and session-level thread ID, allowing a later message to resume from the previous state.
- Because every session initially sent the same cancellation message, the LLM provider’s caching produced the same first-turn reply; Swiggy removed that call and substituted a small pool of static prompts asking for the cancellation reason.

**Tags:** [Architecture](https://yomu.fyi/topic/architecture), [LangGraph](https://yomu.fyi/topic/langgraph), [LLMs](https://yomu.fyi/topic/llm), [Redis](https://yomu.fyi/topic/redis)

- Source: [Swiggy](https://medium.com/swiggy-bytes/from-rigid-rules-to-empathetic-agents-rebuilding-swiggys-order-cancellation-experience-with-llms-6ab01cca1c08)
- Source URL: https://medium.com/swiggy-bytes/from-rigid-rules-to-empathetic-agents-rebuilding-swiggys-order-cancellation-experience-with-llms-6ab01cca1c08
- Ingested by Yomu: 2026-09-09T13:56:52.765Z

[Read original post](https://medium.com/swiggy-bytes/from-rigid-rules-to-empathetic-agents-rebuilding-swiggys-order-cancellation-experience-with-llms-6ab01cca1c08)
