A LangGraph agent with retrieval as a tool
The agent reasons from pairing principles to a wine style, searches Wine Enthusiast reviews with your budget as a filter, recommends one or two bottles with citations, and goes back to re-strategize if its own critique finds a problem.
By Jeremy Lee, WSET Level 3 · Source on GitHub
parse -> strategize -> retrieve -> recommend -> critique --+-- sound --> END
^ (tool call) |
+----------- issues, as feedback ------------+parse | strategize <---------------+ | | retrieve (tool call) | | | issues, recommend | as feedback | | critique ------------------+ | sound --> END
The graph in src/graph.py. Retries stop at --max-attempts (default 2).
From examples/sample_run.md. The agent reasoned to a full-bodied, tannic Cabernet, retrieved six Cabernets (from Napa, Stellenbosch and Mendoza), all at or under $45, and recommended two.
The dish
Grilled ribeye steak with a peppercorn cream sauce
--budget 45
"The structure scours the cream and fat while the oak mirrors the grilled char."
"that grippy structure is exactly what a fatty ribeye needs"
Critique: sound. Every bottle, score and price comes from a retrieved review.
src/pairing.py (acid cuts fat, tannin binds protein, match weight, sweetness tames heat) to choose a style and write a search query.search_wines, a LangChain StructuredTool over a local Chroma index, with the budget as a price filter.[n].--trace times each node and saves the run as JSON. In one traced ribeye run the local search took 0.3 seconds and the four LLM steps took 1.2 to 3.0 seconds each.
AGENT TRACE (node · time · detail) parse 1.2s ribeye · rich body strategize 2.3s style → full-bodied tannic red retrieve 0.3s 6 candidate wines (tool: search_wines) recommend 3.0s drafted pairing with citations critique 2.2s sound
Trace tree as recorded in the README, bullet glyphs dropped.
Pairing quality is not scored against a benchmark, so this shows that the agent works and checks itself, and leaves the quality of its pairings unmeasured. The principles are a short list, retrieval filters on price only, and the default index holds the 30,000 highest-scored reviews.