LangGraph quote agent: approved 1.10, saved 1.25

10 min readKacper KlusekBy Kacper Klusek

On this page10 sections
Title card reading Approved 1.10, saved 1.25, with saved in gold and LangGraph quote agent beneath, the LangChain mark in the top-right corner, beside a printed sales quote for CABLE 3x2.5 where 1.10 is struck through in red next to 1.25 under a gold APPROVED stamp, a hand holding a fountain pen.

A quote agent for a distributor reads an installer’s emailed item list, prices it from the ERP, and waits for a sales rep to approve it. On LangGraph 1.2.24 our test rep approved a cable at 1.10, the price list moved to 1.25 during the pause, and the thread came back approved at 1.25 without asking again. The cause is one line of placement: the ERP read sat in the same node as interrupt(), and that node runs again from the top on resume. We walk through a five-node design that prices before the pause, re-checks after it, writes the quote to the ERP exactly once, and gets tested on past quotes before a rep relies on it.

A quote agent needs five nodes and only one pause

The design splits the job into five nodes, and only one of them waits for a person. This is an example design, not a client project. The job is one wholesale and electrical distributors know well: an installer emails a list of cables, breakers and fittings, and someone has to turn it into a priced quote with stock. On Fastenal’s October 14, 2026 earnings call, its chief executive said AI combined with internal tools can reduce a sourcing and quoting process “from five or six days to about 15 minutes”, which he presented as a branch example rather than an average. Our survey of six distributors’ AI quoting found that none of them published an accuracy figure, which is why the design below keeps a human in the loop on every quote.

The graph has five nodes on LangGraph 1.2.24, the current release on PyPI (uploaded November 20, 2026):

Node Reads Writes Safe to run twice because
extract the email, the catalog line items with item numbers it writes only to state
price ERP items priced lines in state a read changes nothing
approve state only the rep’s answer it holds nothing but interrupt()
recheck ERP items a route a read changes nothing
write_quote ERP quotes one sales quote it looks for the quote before it posts

The ERP in our sketch is Microsoft Dynamics 365 Business Central, because its API is public: the item resource carries unitPrice and inventory per item number, and the sales quote resource takes lines and an externalDocumentNumber. Any ERP with a price read and a quote write fits the same shape, because the ERP stays the system of record and the agent only drafts into it.

The model reads the list and never states a price

The extract node turns the email into rows and leaves every price to the ERP. Each row holds a description, quantity, unit, and the installer’s own part number when there is one. LangChain’s structured output guide gives two ways to get there, ToolStrategy through tool calling and ProviderStrategy through the provider’s native mode, and recommends the second where the model supports it, since there the provider enforces the schema. A Pydantic model is the structured output contract, so a row with no quantity fails validation instead of reaching the ERP.

class Line(BaseModel):
    text: str                     # "3x2.5 YDY cable, 200m"
    qty: float
    unit: str
    customer_part: str | None = None

class ItemList(BaseModel):
    lines: list[Line]

There is no price field, on purpose. Prices come from the ERP in the next node, and a price the model wrote is a price nobody can trace. The same node then matches each row to a catalog item number, stored as sku: a lookup against the catalog with the model ranking candidates, and a row with no clear match goes to the rep marked as unmatched rather than guessed. That routing is a confidence gate on a signal you can check (an exact part number hit, or one candidate far ahead of the rest), never on a confidence number the model reports about itself; our post on deterministic confidence gates covers that choice.

Pricing inside the approval node saved a price nobody approved

The first version of our sketch read prices and asked for approval in one node. It looked tidy and was wrong:

def price_and_approve(state):
    priced = [{**l, **erp_item(l["sku"])} for l in state["lines"]]
    ok = interrupt({"lines": priced})        # the rep sees 1.10
    return {"priced": priced, "approved": ok}

LangGraph’s interrupts guide says why: on resume “the runtime restarts the entire node from the beginning”, so erp_item() runs a second time when the rep clicks approve. We ran it on 1.2.24 with an in-memory checkpointer: the interrupt payload showed a unit price of 1.10, we changed the item to 1.25 before resuming, and the thread finished with priced at 1.25 and approved set to True. Nothing failed, and the approval is attached to a payload the rep never saw.

The graph API guide states the general rule plainly, “Side effects before the pause run again.” A read writes nothing, which is why it is easy to miss, but its result replaces the one the person approved.

The rule: a node that calls interrupt() should read only from state. Whatever the person approves must already be in the checkpoint before the pause.

Freeze the priced quote in state before you pause

Split the node so the approval reads only what is already stored. The price node reads the ERP and writes the priced lines to state; approve contains nothing but the tool approval itself:

def approve(state):
    return {"approved": interrupt({"lines": state["priced"]})}

The priced lines now sit in the agent checkpoint written when price finished, so the payload the rep sees and the lines the quote will carry are the same object. When approve replays on resume it reads that frozen state, and no second ERP call happens inside it. What the rep approved is now a stored record you can show an auditor later.

Re-check prices after the approval, and ask again when one moved

After the approval, compare the frozen prices with the ERP and ask again if any moved. Freezing the quote fixes what the rep sees, and it opens the opposite gap: a quote approved on Monday at Monday’s price may be written on Wednesday, after the price list changed. So recheck sits between the approval and the write:

def recheck(state):
    moved = [l for l in state["priced"]
             if erp_item(l["sku"])["unitPrice"] != l["unitPrice"]]
    if moved:
        return Command(goto="price")         # re-price, ask the rep again
    return Command(goto="write_quote")

In our run the price moved from 1.10 to 1.25 during the first pause, recheck sent the thread back to price, the rep got a second approval showing 1.25, and only the second yes reached write_quote. price ran twice, once per approval, and every ERP read sits outside the node that pauses.

A flow of five nodes, extract, price, approve, recheck and write_quote, with approve highlighted as the only interrupt and reading state only, and a dashed loop from recheck back to price labeled Price moved to 1.25? Back to price, and the rep approves 1.25.
The five nodes of the example quote agent: the ERP is read in price and recheck, never inside approve, and a moved price sends the quote back for a second approval.

Stock is deliberately left out of that comparison. Whether a fall in inventory below the quoted quantity sends the quote back for approval or only adds a lead-time note is a business rule for the sales team, so write it down and test it like any other.

Write the quote to the ERP once, keyed on the email

write_quote must find an existing quote for the email before it posts a new one. It is the only node that changes anything outside the graph, and it will run more than once on a bad day. LangGraph’s fault tolerance guide puts retries at at-least-once: a RetryPolicy reruns the whole node, by default up to 3 attempts, and “Graph writes from a failed attempt are discarded. Side effects during the node (payments, emails, external writes) are outside that boundary. Application code must make those effects idempotent.”

We simulated the classic failure: the ERP commits the quote, the response times out, and the retry posts again. With a plain post, the ERP ended up holding two quotes for one email. Then we made it an idempotent tool call: the email’s message ID goes into state at the start, becomes the quote’s externalDocumentNumber, and the node looks for a quote with that number before posting. Same failure, one quote.

def write_quote(state):
    found = erp_find_quote(external_no=state["email_id"])
    if found:
        return {"quote_no": found}
    return {"quote_no": erp_post_quote(state["priced"], external_no=state["email_id"])}

The guide is specific about where the key comes from: it must be durable before the side effect runs, so generating it inside the same node does not count. The email ID arrives with the input and is in the first checkpoint, which makes it a good key. Read-before-write still leaves a window when two workers run the same thread at once, so a unique constraint on that field in the ERP, where it allows one, is the stronger guard.

Run it on Postgres with sync durability

Pauses that last days need a checkpointer that survives a restart. The checkpointer docs use thread_id as the primary key for every checkpoint, so make it the email ID too. A duplicate webhook is not stopped by that alone: new input on an existing thread, the same page says, “Applies the input to saved state and starts from the entry point.” Have the webhook handler call graph.get_state(config) first and drop the email when the thread already exists. PostgresSaver from langgraph-checkpoint-postgres is a production choice.

Durability is the other setting to choose on purpose. Run a quote agent with durability="sync", which “persists changes synchronously before the next step starts”; "exit" writes only when the run stops, so a crash between price and approve would leave no record that the quote existed. That durable execution is what lets the quote wait at all.

A thread that waits for days also lives through your deploys. Our post on renamed nodes and paused threads shows what a deploy does to a quote waiting at approve, and timeouts, retries and drain covers the rest of the runtime settings. If you would rather run it as a managed service, our LangChain page describes how we deploy these graphs.

Test it on last quarter’s quotes before a rep relies on it

The rep is the safety net, but a rep who corrects every third line will stop reading carefully. Before go-live, build an eval dataset from past quotes: each example is the installer’s original email as input and the quote the rep finally sent as the reference output. LangSmith’s evaluation concepts frame this as offline evaluation, a dataset of examples run as an experiment against each version of the agent.

Three evaluators carry most of the weight for this job:

  • Line match: each extracted line maps to the item number the rep used, with unmatched lines counted separately from wrong ones.
  • Price at approval: every priced line equals the ERP price at the moment of the approval payload, which catches the replay bug above in a test instead of in a customer’s inbox.
  • One quote per email: replaying an example with an injected timeout leaves exactly one quote in a test ERP.

The sent quote is ground truth only after someone checks it, because reps also make mistakes and the agent should not learn them. Run it on every change to the prompt, model or graph before a new version takes real email.

The takeaway

A LangGraph approval is only as good as what the checkpoint held when the person clicked. Put ERP reads in their own node before the pause, keep the approval node to interrupt() and state, re-check prices after the approval and ask again when they moved, and key the ERP write on the email so a retry cannot double it. Then prove each on past quotes, because the bug this avoids never raises an error.

Sources

Want this built and running in production? Soba Labs builds custom AI agents. Talk to us