|
|
ADK with LangSmith for Agent Tracing
Author: Venkata Sudhakar
When an ADK agent produces an unexpected result, pinpointing the cause requires visibility into every prompt sent, every tool called, and every model response received. LangSmith provides a tracing layer that captures this full execution trace, making it easy to replay, compare, and evaluate agent runs.
ShopMax India's customer support agent occasionally gives incorrect refund policy answers. Without tracing, debugging requires adding print statements and re-running scenarios manually. With LangSmith, every agent run is recorded with full context - prompt, retrieved context, model response, latency, and token counts - accessible in a web dashboard.
The below example shows how to wrap Gemini API calls with LangSmith tracing to record agent execution spans.
It gives the following output,
Agent response: Thank you for reaching out to ShopMax India. Regarding your laptop
purchased 3 weeks ago, our return policy allows returns within 30 days of purchase
with the original receipt. However, electronics must be unopened for a standard return.
For a damaged screen, we recommend checking your 1-year manufacturer warranty which
covers manufacturing defects. Please visit your nearest ShopMax store with the receipt.
Trace recorded in LangSmith dashboard under project: shopmax-support-agent
Each @traceable decorator creates a span in LangSmith - the outer support_agent span contains child spans for each gemini_call and lookup_policy invocation. In the LangSmith dashboard you can see the full trace tree, latencies, token counts, and inputs/outputs at every step. Use LangSmith datasets to run regression tests against a saved set of queries, ensuring agent improvements do not introduce regressions.
|
|