My App
AI SystemLLM System

Question Routing

The router decides how an in-scope question is answered. Some questions need an exact value from the database, such as a count, which retrieval over notes cannot reliably give. Others need the free-text notes.

  • Structured output (Pydantic model): a binary answer and a short reason.
  • Structured: the answer is an exact value a query returns, such as a count of pieces (optionally filtered by stage, location, or time) or a lookup of one column for a named piece, such as its current stage or location. These go to the SQL agent.
  • If the SQL agent fails: the turn falls back to retrieval and answers from the notes instead of returning an error. The agent fails when it still has no valid, working query after its retries. A query that runs but returns no rows is not a failure; it is answered as a normal result.
  • Everything else: open-ended, advisory, or descriptive questions, such as why something happened, what to do next, or a summary of the user's work. These go to retrieval.
  • History-aware: like the classifier, the router sees the conversation.
  • If the router fails: the turn also falls back to retrieval.