Cap a queue agent's actions by rollout phase

Agent buildEasy10 minServiceNow style

Your task

Your support queue sometimes blows through its response targets (service level agreements, or SLAs) before anyone notices. An agent predicts breaches, and its autonomy grows with each rollout phase the team approves.

Write decide_queue_action(phase, minutes_to_breach, minutes_since_alert, human_acked): the rule your agent follows for each ticket at risk.

  • phase (str): the rollout phase, such as "shadow".
  • minutes_to_breach (int): predicted minutes until the ticket breaches its SLA. It may be negative.
  • minutes_since_alert (int): minutes since the agent first alerted on this ticket.
  • human_acked (bool): a person has acknowledged the alert.
  • Return "log", "alert", "reprioritize" or "page". They form a ladder in that order, from least action to most.

Rules:

  1. The phase sets a cap on the ladder: shadow caps at "log", alert at "alert", assist at "reprioritize" and autonomous at "page". Phases match exactly, and any other phase, an empty one included, caps at "log".
  2. The signal sets the action the agent wants. The first match wins:
    • minutes_to_breach above 60: "log".
    • human_acked: "alert".
    • minutes_to_breach at most 15 and minutes_since_alert at least 15: "page".
    • Otherwise: "reprioritize".
  3. Return the lower of the wanted action and the cap.

Examples

decide_queue_action(phase: str, minutes_to_breach: int, minutes_since_alert: int, human_acked: bool) -> str
Example 1
Inputdecide_queue_action("shadow", 10, 30, False)
Output"log"
Example 2
Inputdecide_queue_action("assist", 40, 5, False)
Output"reprioritize"
Example 3
Inputdecide_queue_action("autonomous", 10, 30, False)
Output"page"