Design pattern
Config-driven use-case engine
Use cases stored as versioned database records. New use cases ship with no code changes, and deterministic steps skip the LLM.
The problem
Each new review type was a hard-coded workflow. Adding one meant new code, a new deploy and more tokens, even for steps that only needed a fixed query.
The approach
- Three tables describe a use case, its ordered queries, and the mapping between them; a flag marks which steps need LLM reasoning.
- An intent classifier routes each question to a predefined template, dynamic text-to-SQL, or a clarifying question.
- Steps that need no reasoning run as plain SQL and fill templates directly; the LLM only writes the summary and judgment.
What I learned
- Moving behaviour from code into configuration makes an agent faster to extend and easier to review.
- The cheapest LLM call is the one you don't make.