Agentic AI · Advanced level

Advanced level · Module 4: Routing and Specialist Agents · Lesson 2 of 3

Implementing and Hardening Routers

Learners combine simple rules with model classification, validate the chosen route, use confidence thresholds and send uncertain requests to a safe fallback.

In this lesson you will

  • Implement a hybrid rule and model router
  • Apply confidence thresholds and fallbacks

Key concepts

rule-based routingmodel-based routingvalidated routeconfidence thresholdfallback route

The lesson

Rules handle clear cases cheaply and predictably (messages mentioning 'complaint' go to a person). The model classifies the rest into a fixed list of routes, returned as validated structured output with a confidence value.

Below a confidence threshold, or for an invalid route, the request goes to a fallback: a general agent with limited abilities or a human queue.

Prevent loops: a specialist can return a request to the router only once; after that it goes to a person.

Step by step

  1. Write three routing rules.
  2. Add model routing with validated route and confidence.
  3. Set a threshold and fallback.
  4. Add a loop guard and test it.

Practice activity

Implement the capstone router with rules, validation, threshold, fallback and loop guard.

Expected result: A router that handles clear, uncertain, invalid and looping cases safely.

Check your understanding

  1. Why combine rules with model routing?

    Show answer

    Rules handle clear cases cheaply and predictably; the model handles the rest.

  2. What prevents routing loops?

    Show answer

    Allowing a request to be returned to the router only once, then sending it to a person.

Further learning

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.