← Production Insights

#21

AI Interruptions: A Workflow Orchestration Challenge

The challenge of handling interruptions in a production AI agent isn't detecting that the user changed the topic.

It's deciding what that change means for the workflow already in progress.

A user asking a new question doesn't necessarily mean they're starting a new task.

And a user starting a new task doesn't necessarily mean the previous workflow should be cancelled.

This is where I usually add another variable inside currentTurn:

flowRelation: How does the current user request relate to the existing workflow?

Instead of treating every incoming message as an independent intent, the agent can classify its relationship to the current workflow.

  • newTask
  • continueFlow
  • sideQuestion
  • resumeFlow
  • cancelFlow
  • unclear

But classifying the interruption is only one part of the problem.

The second part is managing the workflow lifecycle.

This is why I keep flowRelation in currentTurn and the workflow's execution status inside flowContext.

The status describes the current lifecycle state of the workflow:

  • active
  • waiting_user to provide something
  • paused
  • completed
  • cancelled

A production agent doesn't just need to know what to do next.

It needs to know what to preserve, what to suspend, and what to resume.

Handling interruptions isn't just a conversation problem. It's a workflow orchestration problem.