Models, Retrieval, Tools, and Control Flow › Running it on a real query

Michael BrenndoerferDecember 2, 20261 min read
Language AI HandbookAll chapters
Part 64 of 67Compound AI System Design
Chapter 485Models, Retrieval, Tools, and Control Flow › Running it on a real query
Reading section 6 of 11 · Running it on a real query · 1 minSection 6 of 11 · 1 min

Section 6 of 11 · 1 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

The availability query below leaves the size-matching Trail Runner Pro. The stocked fixture reports two units. The second run uses the same query, catalog, parser and generator with the inventory fixture unavailable. You can see the distinction between a matching catalog product and an observable stock count.

PythonIn [13]
CollapseExpand
QUERY = "Is the Trail Runner available in size 10 under $120?"
STOCK = {("p1", "10"): 2}

available = run_assistant(QUERY, STOCK)
partial = run_assistant(QUERY, None)
for answer in (available, partial):
    print(f"{answer.outcome.value}: {answer.text}")
    print("Trace:", " → ".join(answer.trace))
ConsoleOut [13]
CollapseExpand
complete: Trail Runner Pro at $110. Size 10: p1: 2 in stock.
Trace: parse → retrieve → filter → generate → validate → lookup
partial: Trail Runner Pro at $110. Stock is unknown.
Trace: parse → retrieve → filter → generate → validate → lookup → stock_unknown

The display text for an availability question includes a product ID next to the count. A UI may already have a name-to-ID mapping from retrieval. Here we keep the literal ID in the output so it is clear which fixture entry supplied the number. The trace on the available run has the same initial stages as the trace on the unavailable run. Its last entry differs because the unavailable run records the separate stock-unknown decision.

PythonIn [14]
CollapseExpand
print("Status:", ", ".join(available.status))
print("Cited catalog rows:", available.product_ids)
print("Partial path final stage:", partial.trace[-1])
ConsoleOut [14]
CollapseExpand
Status: Searching the catalog, Checking stock
Cited catalog rows: ('p1',)
Partial path final stage: stock_unknown

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy