Tracing tool-call vs tool-output costs separately in LangChain with Arize Phoenix

Normal-Blueberry-385 · reddit · 2026-09-03

A developer shares an observability setup for LangChain apps using Arize Phoenix + OpenTelemetry, arguing four metrics must never be collapsed: LLM tool-call generation tokens/cost, tool execution (name, args, latency, output size, provider cost), tool-output consumption as next-request input tokens, and the final LLM response. Implementation uses a custom BaseCallbackHandler with a unique tool.call.id to correlate parent/child spans (LLM → tool → next LLM), plus centralized pricing config, sensitive-argument masking, and fail-safe tracing that never breaks agent execution. A worked example shows a tool's 850 output tokens measured separately from the 1,478 input tokens of the following LLM call.

Original post →

More from coding & agent

coding & agent channel →