Agents Need Feature Flags - Sachin Gupta

AI Engineer · 19 min · 272 sentences · from YouTube's caption track

Each timecode opens YouTube at the start of that sentence. Line anchors (#s42) are the cue ids in the WebVTT, and every line carries its start and end seconds. All transcripts has every talk, and the whole corpus as one file.

  1. 00:00Hello everyone, I'm Sachin Gupta and I'm a backend engineer and today we are going to talk about agent need feature flags.
  2. 00:08If you have been a backend engineer for any length of time, you already know these tools.
  3. 00:14Things like canaries, segment targeting, kill switches, your craft has had them for over a decade and none of them is new.
  4. 00:23The boring infrastructure that keep deploy safe is already a solved problem.
  5. 00:29What is new is that we are shipping the most behavior changing systems we have ever built agents that send money, agent that send mail, agent that modify databases, agent that spawn child processes
  6. 00:43and we are shipping them with none of that infrastructure.
  7. 00:47We are shipping them the way web team used to ship in 2008.
  8. 00:52Over the next few minutes, here is the plan.
  9. 00:55I will walk you through with the six flag types that agents specifically need.
  10. 01:00I will show you two live demo storyboards.
  11. 01:03The first is flipping a tool midcon conversation.
  12. 01:06The second is stopping a runaway agent mids sentence.
  13. 01:10Then I will cover a rollout playbook with the numbers your team should track from day one.
  14. 01:17Let's go.
  15. 01:20Here is a situation today.
  16. 01:22The moment your prompt change merges, 100% of your users see the new behavior.
  17. 01:27There is no canary, no segment, and no roll back button.
  18. 01:32Look at what goes out under those small all or nothing rules.
  19. 01:38We get prompt rewrite, new tool addition, model swapping, memory policy changes, autonomy upgrades, system instruction edits, and we get all of it globally and instantly.
  20. 01:51Web teams stopped doing this back in 2012 and they stopped doing it for changes that were less risky than this.
  21. 01:59The story that you actually hear from teams almost word for word is that it's just a small prompt peak maybe broke a couple of a chunk of users and then finally
  22. 02:10people are finding it out on discord links or Tik Toks or maybe another social media platform.
  23. 02:18So that is the failure mode this entire talk is built around and let me show you that it is not hypothetical.
  24. 02:31These are the four named incident in the last 14 months.
  25. 02:35The first one we have is cursor sam that happened in April of 2025 where the support bot confidently told users about a policy that never existed.
  26. 02:46The second one we have is replet.
  27. 02:48This was day nine of a 12-day wipe coding experiment.
  28. 02:53The agent did not follow the instructions and ended up deleting the production database and then fabricated over 4,000 fake users to conceal what it had done.
  29. 03:03The third one is LANC chain.
  30. 03:05It had a four agent pipeline researcher, analyzer, verifier, and synthesizer where two of them ran in continuous loop and costed $47,000.
  31. 03:16The fourth one is pocket OS where a developer was using cursor and claude.
  32. 03:21The AI coding agent grabbed an unrelated API token from another file, treated it as authoritative, and ran a railway graphql drop on the production database.
  33. 03:33On the bottom left, you will see the sources that I used to site it.
  34. 03:42Web engineers learned this lesson a decade ago.
  35. 03:44Canary releases.
  36. 03:45You ship to a few percentage of users.
  37. 03:47You watch the matrix.
  38. 03:49If it works, you expand.
  39. 03:50If it doesn't, then you roll back.
  40. 03:53Segment targeting.
  41. 03:54Different behavior for different type of users.
  42. 03:56Kill switches.
  43. 03:57Pre-wired off toggles that take effect in seconds, not in deploy cycles.
  44. 04:02Rollout monitoring.
  45. 04:03Every change has its own error rate dashboard.
  46. 04:06None of this is new.
  47. 04:07The tooling already exists like launch darkly, unleash lift or maybe your homegrown flag service.
  48. 04:13This is already a solved problem.
  49. 04:14The discipline is already there.
  50. 04:16We just have to apply it.
  51. 04:19But now the problem is that web feature flags covers one thing whether a feature is on or off.
  52. 04:25But agent has six behavior surfaces that a cred app does not have and each one needs its own kind of flag.
  53. 04:33And in the next slide we are going to see that these are the six behavior surfaces that a cred app does not have.
  54. 04:40First one is prompts.
  55. 04:42The system prompt is your most behavioral altering code.
  56. 04:44It changes weekly sometimes daily often outside your normal deploy processes.
  57. 04:49Tools.
  58. 04:50Every tool the agent can call is the new authorized action.
  59. 04:55Tools comes and go faster than features ever did.
  60. 04:59Models.
  61. 04:59Model of the week swap change personality, refusal patterns, latency, and cost.
  62. 05:05Sometimes in subtle way you won't even notice for days.
  63. 05:08Memory.
  64. 05:09What the agent remember across session silently changes behavior over time.
  65. 05:14The same prompt reduces different output for the same user as memory accumulates.
  66. 05:21Autonomy, suggest versus auto approve versus autoexecute.
  67. 05:26The single largest blast radius tile you own.
  68. 05:30Sub aents.
  69. 05:31These are the spawn children inherited from the parent flags or they should most system don't enforce it.
  70. 05:39A boolean feature enabled flag doesn't cover any of these.
  71. 05:43You need a taxonomy.
  72. 05:49So here it is six type one for each surface prompt variant tool access model routing memory policy autonomy level and the kill switch.
  73. 05:59Each one maps to a behavior surface.
  74. 06:02None of them require building a new flag back end.
  75. 06:05Let me walk through them fast.
  76. 06:09Prompt variant flags route different users to a different system prompt version on the fly without a deploy.
  77. 06:16Look at the example.
  78. 06:17The beta cohort get experimental V3 which is concise and action first.
  79. 06:22Paid tier gets V2 which is warm and expensive.
  80. 06:26Everyone else gets V1 which is stable and well tested.
  81. 06:30Cursor SAM is what happens without this.
  82. 06:33There was no controlled variant just one model doing its best.
  83. 06:37It got things wrong differently for each user.
  84. 06:40With a prompt variant flag you roll the new prompt to 5% of beta traffic.
  85. 06:45You watch the hallucination rate.
  86. 06:47You watch the escalation rate.
  87. 06:49And then you promote when it holds.
  88. 06:52Tool access flags authorize or revoke specified tools per user segment, per user type, per risk class.
  89. 07:00The tool exists in your codebase whether the agent can call it.
  90. 07:04It is the flag.
  91. 07:05This is mandatory when your agent has money moving tools, data deleting tools or compliance sensitive tools.
  92. 07:12you scope per customer tier or you pay the AML or socks bill along the way.
  93. 07:19It prevents the usual broken tool ship.
  94. 07:22The prompt plus send email massmail incident and the beta tool that leaks to prod users through coding d uh through config drift model routing flag decide which model handles which traffic.
  95. 07:35They let you migrate fallback or canary without code changes.
  96. 07:39The high cost segment gets the frontier model.
  97. 07:42The free trial gets the cheap first model and on an incident, one flip puts you to a stable fallback.
  98. 07:48The lesson is extremely simple.
  99. 07:51On the day a provider deprecates a model or pulls one for safety or has a multi-hour outage, a model routing flag is the difference between flipping a switch and shipping a hot fix in the middle of an incident.
  100. 08:04If your production system has a hard dependency on one model from one provider and it does not have any routing flag, no fallback, you are one provider outage away from a complete agent outage
  101. 08:18or maybe one deprecation notice and everything is gone.
  102. 08:22Route your traffic have a fall back.
  103. 08:25Make it a flag.
  104. 08:28Memory policy flag controls what the agent remember across sessions.
  105. 08:33These are four dimensions and each of them are independent.
  106. 08:37The first one is retention.
  107. 08:39It could be session only.
  108. 08:40It could be 30 days or forever.
  109. 08:42Scope.
  110. 08:43It could be per user, per tenant or maybe global.
  111. 08:46Write enabled.
  112. 08:48Whether the agent can persist memory for this segment at all or not.
  113. 08:52User visible.
  114. 08:53Whether the user can inspect and delete their own.
  115. 08:56They all look small but they are not.
  116. 08:58The privacy posture of your product lives here.
  117. 09:01The consistency of your agent behavior lives here.
  118. 09:04Your compliance story with GDPR and EU AI act lives here.
  119. 09:10Autonomy level flags.
  120. 09:11This is the single biggest blast radius dial you own.
  121. 09:15There are three settings.
  122. 09:16Suggest where the agent recommend and a human acts.
  123. 09:20Auto approve where the agent prepares and a human one click confirms.
  124. 09:24And autoexecute where the agent just does it.
  125. 09:28The kill switch pre-wired off agentwide and poor surface.
  126. 09:32It does not require any deployment, does not require any start, does not require any code changes.
  127. 09:39Three properties that make a kill switch a real kill switch.
  128. 09:43First, you flip it and the change takes effect in seconds, not in a deployment pipeline.
  129. 09:49Second, inflight request respect the flag at the next decision point.
  130. 09:55Third, the wiring exist from the agent design phase, not at 3:00 a.m. hot patch when something is on fire.
  131. 10:03Without one, here is what you're going to get.
  132. 10:08First, Lchain, second pocket OS, third replet, and fourth is open clock.
  133. 10:15Now, think if you had a kill switch, if you could just have terminated the operation in between, it would have changed the game altogether.
  134. 10:25Okay, now is the time for the demo.
  135. 10:27The setup is basically assume you are in the April 2025 where the cursor sort bot is confidently citing a policy that is not present.
  136. 10:38So the way we think we can fix it is with the tool access flag.
  137. 10:42On the left you see we are having a conversation on the right the fix.
  138. 10:47So the moment we switch off this flag it will say it's disabled it at this time.
  139. 10:54by this person.
  140. 10:55This is the scope.
  141. 10:57This is what it applies and these are the active sessions.
  142. 11:00The moment the flag is flipped, you will see that instead of citing a wrong policy, it is saying I can draft this for you, but I'm not able to send emails right now.
  143. 11:11Want me to copy the draft into your clipboard instead?
  144. 11:15Now, this is a graceful error.
  145. 11:17Instead of giving me the wrong details, it is telling me that it cannot perform the operation.
  146. 11:24Now the money shot.
  147. 11:26The setup here is it's November 2025.
  148. 11:29A four agent Langchain pipeline loop for 11 days and burned $47,000.
  149. 11:35The agent system never noticed.
  150. 11:37The billing dashboard tripped the threshold.
  151. 11:40The chart on the left is tool calls per minute.
  152. 11:43This is an illustrative simulation.
  153. 11:45Baseline is 4 to8.
  154. 11:47The agent enters a runway loop.
  155. 11:50The line climbs rapidly.
  156. 11:51At t + 15 seconds, the raid guard fires a slack alert.
  157. 11:55At t + 2022, I flip the agent to kill it.
  158. 12:00At t + 2026, every inflight agent process sees the flag at its next decision point.
  159. 12:07Each one emit a graceful shutdown.
  160. 12:10At t + 30, the cost graph flattens.
  161. 12:1430 seconds from problem to mitigation without any deployment, without any restart, without any code changes, no incident channel paging.
  162. 12:24And this is what you get with the kill switch.
  163. 12:27Now the question is where the flag layer is actually living.
  164. 12:31If you see this architecture is extremely simple.
  165. 12:34There are three boxes.
  166. 12:35user on the left, a middleware layer in the middle which resolve the flag, gets the tools, route the models, applies autonomy and honor the kill switch and the agent loop on the right with model tool memory and sub agents.
  167. 12:49The agent loop is unchanged from whatever you have today.
  168. 12:53Below the middleware is your flag back end which is unleash flip launch darkly or maybe homegrown.
  169. 13:00You are not building a new one.
  170. 13:02The critical architecture rule is on the call out at the bottom of the slide.
  171. 13:07Sub agents must go through the same middleware.
  172. 13:11The biggest failure mode I see is a parent agent with flags properly applied that spawns a child agent.
  173. 13:18The child call the model and the tools directly but bypass the middleware entirely.
  174. 13:24The kill switch you just flipped never reaches it.
  175. 13:28So wire the middleware into every agent that is being spawned not just at the entry point.
  176. 13:35So this is the rollout playbook.
  177. 13:37Five steps in exact order.
  178. 13:40Step one, kill switch first.
  179. 13:42Wire a single agentwide kill switch and one per tool kill switch.
  180. 13:47Ship those before anything else.
  181. 13:49The step two is wrap the tools.
  182. 13:51Every tool call resolve a flag before execution.
  183. 13:55Step three stage autonomy.
  184. 13:57Default everything to suggest.
  185. 13:59Auto approve per surface as you build trust.
  186. 14:02Auto execute is optin per tool.
  187. 14:05Step four is variant prompts.
  188. 14:07Move the system prompt out of the code and into a flag resolve config.
  189. 14:13Step five, watch the slope.
  190. 14:15What does watch actually mean?
  191. 14:18Four numbers you should track from day one.
  192. 14:21These are on the right side of the slide.
  193. 14:23The thresholds I'm about to give you are suggested defaults.
  194. 14:27Tune them as per your requirement, your surface, your severity, your traffic class.
  195. 14:32First one, kill switch fires per week.
  196. 14:35The target is zero.
  197. 14:37If you have more than two a week, then investigate roll back time to mitigation.
  198. 14:42Target is under 5 minutes for a kill switch and under 30 minutes for a prompt roll back.
  199. 14:48If you're slower, your mitigation doesn't fit inside a real incident window.
  200. 14:53Canary error rate delta.
  201. 14:55If a new prompt variant error rate climbs more than 2% over baseline at 5% rollout, block the promotion flag audit trail completeness.
  202. 15:06100% required.
  203. 15:08If you cannot audit, who flipped, what is flipped, when it was flipped, then you cannot debug an incident in retrospective.
  204. 15:21Five failure modes that I have watched play out at multiple teams.
  205. 15:25Flag resolved at session start, not per turn.
  206. 15:28Your kill switch actually fired, but inflight conversation don't see it until the next session.
  207. 15:34Sub agents bypass the middleware.
  208. 15:36This one we have already covered.
  209. 15:38We need to make sure that we wire the middle middleware into every spawn.
  210. 15:45Context drift flags.
  211. 15:46The user segment at turn one is stale by turn 20.
  212. 15:50Log the segmentation context at the conversation level.
  213. 15:54Caching defeating the flip.
  214. 15:57Aggressive caching at your LLM gateway returns the old prompt response even after the flag is flipped.
  215. 16:03No alert on kill switch fires.
  216. 16:05The switch goes off silently.
  217. 16:07The product owner finds out next week.
  218. 16:10Every kill switch fire is a page on its own.
  219. 16:15In this slide, what you are seeing is the two parts to the business case.
  220. 16:18On the top half, the five questions every enterprise buyer will ask you in the next 12 months.
  221. 16:24Can you show me the kill switch?
  222. 16:26What's your rollout policy for prompt changes?
  223. 16:28How do you isolate beta features from production users?
  224. 16:31When a model behaves badly for one cohort, how fast can you mitigate?
  225. 16:36Who can flip these flags and is it audited?
  226. 16:39If you cannot demo all five, you are going to lose the deal.
  227. 16:43Flags are the demo.
  228. 16:45And on the bottom half, this is no longer just a sales question.
  229. 16:49It's a regulation.
  230. 16:50EU AI act, Mopar versus Air Canada, Garcia versus Corrector AI.
  231. 16:57These are the four habits that actually defeat the whole point.
  232. 17:01Kill switches rot.
  233. 17:02They get wired on day one and then never trade.
  234. 17:056 months later, a config migration broke the flag and the time you need it, it does not fire at all.
  235. 17:12Flag scrolling.
  236. 17:13You have 600 flags, no documentation.
  237. 17:16Every flag is a hidden coupling between the unrelated systems.
  238. 17:20Every flag needs an owner and a removal date.
  239. 17:23The temporary flag, it is shipped for a roll out.
  240. 17:26It was never removed.
  241. 17:285 years later, it's somehow loadbearing.
  242. 17:30Kill it immediately after the roll out is done.
  243. 17:33Flagdriven prompt.
  244. 17:34It fs that nobody test the street.
  245. 17:37Six prompt variant live in a production.
  246. 17:40Each individually works.
  247. 17:41Together they are amaze.
  248. 17:43Test the cartician product.
  249. 17:47Now these are the three things that you should remember.
  250. 17:50First one and the most important one in my opinion.
  251. 17:52Ship the kill switch first.
  252. 17:54If you do nothing else, give your agent one agentwide kill switch and one per tool kill switch.
  253. 17:59They take effect in seconds.
  254. 18:01No deployment is needed.
  255. 18:03That single capability changes your operational posture more than any engineering team investment in this particular quarter.
  256. 18:12Second one is treat the six surfaces independently and measure the slope prompts tools models memory autonomy sub aents.
  257. 18:21Each one needs its own flag type.
  258. 18:24On top of the taxonomy, track the four numbers, kill switch fires per week, time to mitigation, canary deltas, and audit completeness.
  259. 18:33Remember, 2026 was all about adoption.
  260. 18:372027 is all about control.
  261. 18:40The number three, match the discipline to the blast radius.
  262. 18:44Your boring web app sits behind canaries and segments.
  263. 18:48Your agent can send email, move money, modify database, and spawn children.
  264. 18:53It deserves at least the same discipline or probably more.
  265. 18:57Thank you very much.
  266. 18:59Build the kill switch this week.
  267. 19:01Everything else is the iteration on the same idea.
  268. 19:04Every incident on this deck is sourced.
  269. 19:06The curated case studies are linked on the screen at github.com/vectra/ awesome agent failures.
  270. 19:13Thank you very much.
  271. 19:14I'm Sachin Gupta.
  272. 19:15Thank you for watching.