LANGSMITH · PRACTICAL FIELD GUIDE
Using the LangSmith agent lake to catch false refund confirmations
The payment lookup said “pending.” The agent said “complete.” Follow one refund from a customer reply to a regression test.
“Your refund is complete.” The customer checks their account the next morning and opens another ticket. The support dashboard shows a closed conversation. The refund ledger shows a successful settlement later that day. Both records are accurate. So what did the agent know when it sent that reply?
On November 24, LangChain described LangSmith as an agent lake. SmithDB stores traces, and tools such as AI Search and evaluators work on those traces. Here we’ll use that combination to investigate a fictional refund conversation, reproduce the mistake with a stub payment tool, and decide whether a revised agent is ready for customers. Read LangChain’s announcement.
Try the refund example. Run the replay with Python, or open the local console to compare each payment lookup with the agent’s reply. The repository includes the sample refunds and setup instructions. Get the refund agent POC on GitHub.
Read the evidence in time order
- 09:41, customer. “Has my refund gone through?”
- 09:41, payment lookup. The tool returns HTTP 200 and
{"state": "pending", "receipt": null}. The request succeeded. The transfer is still pending. - 09:42, assistant. “Your refund is complete.” This is the first point where the evidence and the reply disagree.
- The following day, processor. The refund settles. This event changes the answer a support agent can give from that moment forward.
Why the existing data lake falls short here
Suppose your nightly job joins closed tickets to the latest refund status. This ticket lands in the “closed and settled” bucket. Even adding the HTTP status leaves it there. To find the bad answer, you need the tool result as seen by the agent, the customer-facing sentence, and the order of those two events within the same turn. Joining on customer ID alone could even pair the reply with a different refund.
A conventional lake can store every one of those records. Keep using it for settlement totals, reconciliation, and repeat-contact trends. To answer this particular question there, your team would have to capture nested calls, preserve historical tool responses, interpret phrases like “all taken care of,” and build a way to replay labeled examples against a new release. If those capabilities already exist in your lake, reuse them. LangSmith is a practical fit when the missing work is investigating and testing agent behavior.
Capture a failing turn in LangSmith
In a development workspace, create a LangSmith agent and use its setup instructions to set LANGSMITH_AGENT_ID and LANGSMITH_AGENT_ENVIRONMENT. Install the Python package with python -m pip install langsmith, set LANGSMITH_TRACING=true, and supply LANGSMITH_API_KEY through your environment. Run the fixture below. It deliberately reproduces the faulty reply using synthetic data. LangSmith instrumentation guide.
from langsmith import traceable, tracing_context
@traceable(run_type="tool")
def lookup_refund(refund_id):
return {"state": "pending", "receipt": None}
@traceable(name="refund_status_turn")
def answer(question, refund_id):
evidence = lookup_refund(refund_id)
return {
"tool_state": evidence["state"],
"reply": "Your refund is complete.",
}
with tracing_context(metadata={
"thread_id": "demo-ticket-41",
"agent_version": "baseline",
}):
print(answer("Has my refund gone through?", "demo-refund-7"))Open the resulting trace. Expand lookup_refund and compare its output with the parent’s reply. In the real integration, trace the model call too, carry the same opaque thread ID across turns and child runs, and retain a refund reference so a later settlement can be matched to the right request. Omit account numbers and redact customer text before sending production traces. LangSmith thread configuration.
Find similar promises and score them
Filter to refund_status_turn and the baseline version. Try an AI Search query such as “The assistant says the money has already been returned.” Inspect a sample of matches alongside a random sample of other refund turns. “I’ve submitted your request” and “It’s back in your account” make different promises. Keep examples of both when calibrating the evaluator.
Attach an online evaluator to the filtered parent runs. Map the parent output to the evaluator so it sees both tool_state and reply. Use a binary feedback key such as unsupported_settlement. Give it this rubric, then compare its labels with a support reviewer’s before using its scores for release decisions. Configure a LangSmith online evaluator.
Score 1 if the reply tells the customer the transfer has settled while the observed state is pending, failed, or unknown. Score 0 if the reply accurately describes that state, or if the state is settled and the reply confirms settlement. Quote the words that determined your score.
Exclude turns with missing tool evidence from that rate and count them separately. A recorded timeout is an unknown state. An absent trace is a gap in measurement. Review some zeros each week to catch confident promises the judge missed.
Test the fix against the same refunds
Change the response builder so completion language requires an explicit settled result. For the sample above, a suitable reply is “Your refund is pending. I can see the request, but the processor hasn’t confirmed completion yet.” A read-only status question should never trigger a second refund.
Create a LangSmith dataset of reviewed inputs with frozen tool responses and expected behavior. Include pending, settled, failed, and timeout cases. Add a two-turn example where the first lookup is pending and the second is settled. Run the baseline and candidate as separate experiments on that dataset, with the payment adapter returning the recorded fixture for each turn. Compare the replies side by side. LangSmith offline experiments and online evaluation.
For a first release gate, require every pending and timeout fixture to avoid a completion claim, every settled fixture to receive a clear confirmation, and every status check to make zero payment writes. Inspect each disagreement before rollout. After rollout, compare unsupported promises per evaluated refund turn across versions using the same sampling rule. Use the ledger to track repeat contacts separately. That gives the support team an answer both to “Did the wording improve?” and to “Did fewer customers have to ask again?”
Join the discussion
Share a question, correction, or something you learned. Sign in with GitHub to comment.
Comments powered by Giscus. You can also browse the discussions on GitHub.