Skip to Content

How do I see the prompts and responses in an agent built with LangChain?

Rius shows LangChain prompts and responses on the Input / Output tab of each model-call span, recorded automatically once you call rius.init(). The LangChain integration hooks LangChain’s callbacks, so chains, tools, retrievers and model calls become spans with their messages and you add no tracing code. Open a trace, select the model-call span and read the prompt and completion there. Content capture is on by default and you can turn it off. See Monitor AI agents in production for the wider picture.

How it works

The LangChain integration hooks LangChain’s callback system, so anything that runs through it is traced: LCEL chains, agents and LangGraph nodes.

  • What it records on its own. One span per step, typed by what the step is. Chains are CHAIN spans, tool invocations are TOOL spans, retrievers are RETRIEVER spans, and model calls are LLM spans with the model, token usage and messages. Cost is computed by Rius from the model and token counts.
  • What counts as content. All step inputs and outputs, and all messages, are content attributes. The privacy controls apply to the whole tree, so one setting covers prompts, responses and the data that moves between chain steps.
  • Nesting. The spans follow your chain structure, so the trace reads like your execution graph.
  • Where it shows. The span detail panel has an Input / Output tab that renders the prompt and completion when the span carries content. The Raw tab shows the span exactly as ingested.

If you also install a client extra such as openai, LangChain’s chat model span wraps the client library’s span, so you get framework context and client-level detail, nested. Each chat model call is counted once in tokens and cost. Text-completion models (BaseLLM subclasses, such as langchain_openai.OpenAI) are still counted twice. The integrations overview links to the cases and which layer to keep.

Set it up

  1. Install the integration and initialise Rius. The extra installs the instrumentation, not langchain itself. In TypeScript the equivalent is npm install @arizeai/openinference-instrumentation-langchain, and await rius.ready tells you whether langchain attached.
# pip install "glassflow-rius[langchain]" langchain import rius rius.init(api_key="ri_...", service_name="my-agent") # build and run your chains exactly as before
  1. Run one chain that calls a model. You change nothing in the chain.
  2. Open Traces and click the run. In the waterfall, select the model-call span. LLM spans show their token counts inline, so they are easy to spot. To jump straight to model calls, use the Spans tab and pick LLM from the All kinds menu.
  3. Open the Input / Output tab. On a span with captured messages, Since previous llm call switches the input to what changed since the trace’s previous model call. In an agent loop this shows what each step added to the prompt, and a dropped turn or a rewritten system prompt stands out.
  4. Add a span of your own only for code the LangChain callbacks do not see, such as a plain function that does its own work between chain runs. Wrap it with rius.observe. A bare observe makes a CHAIN span named after the function, and it appears in the same trace.
@rius.observe def handle(query: str) -> str: ... # your own code, then your LangChain call
  1. To keep prompts and responses out of Rius, set RIUS_CAPTURE_CONTENT to false. Rius then strips prompt and response content at export, and the Input / Output tab says there is no content. Timings, tokens and cost still work.

To find a run, read Exploring traces. The search box on Spans matches span names, span IDs, trace IDs and session IDs, not prompt text. Attribute filters match exact values only, and prompts and completions are left out of the suggested filter values, so you locate a trace by agent, time, status or span kind first and then read its content in the span.

What you get

  • Prompts and responses on the span for each model call, with the model, token counts and a computed cost next to them.
  • Inputs and outputs for chains, tools and retrievers, each on its own span, so you can see what each step received and returned.
  • A trace that mirrors your chain or LangGraph structure, with failed spans highlighted along the path from the root to the error.
  • A prompt diff between consecutive model calls, to see what changed in the conversation.
  • One content setting that covers the whole tree, so you decide once whether prompts and responses leave your process.
  • Costs that are list-price estimates in US dollars, not billed amounts. A call that reported no token usage shows a blank cost rather than $0.

When something else fits

  • If your model calls do not go through LangChain, check the integrations list for the library you use, or wrap your own code with observe.
  • If you need prompts out of Rius for privacy reasons, turn content capture off and keep the structure, timings, tokens and cost.

Still stuck? Get help

Last updated on