Skip to Content

How do I see the prompts and responses in an agent built with the Claude Agent SDK?

Rius shows prompts and responses for a Claude Agent SDK agent on the Input / Output tab of the generation span you wrap around the query loop.

The Claude Agent SDK runs the Claude Code runtime in a separate process, so nothing records the prompt or the reply on its own. You add two things: an observe root for each task and a manual generation that holds the task as its input and the collected answer as its output. Open the trace in the console and select that generation to read both, next to its model, tokens and cost.

How it works

For this framework the integration is manual, so the trace contains only what your code records.

  • Recorded on its own: nothing. No model client runs in your process, so auto-instrumentation has nothing to hook.
  • Your observe wrapper: makes each task the root AGENT span.
  • Your generation: wraps the query() loop. You pass the task as input, collect the text blocks of each assistant message, and set that text as the output. The run’s ResultMessage fills in token usage and the real model id, and Rius computes cost from them.
  • Where it shows: a task appears as an AGENT span with one LLM child, here named claude_agent_turn. The prompt and the answer sit on that child.

The prompt you see is the one you pass as input, and the response is the text you collect. The runtime’s inner work, such as tool calls, sub-turns and file operations, produces no spans, so those inputs and outputs are not in the trace. The generation records the turn’s totals only.

Content capture is on by default. If the SDK’s privacy controls strip content, for example with RIUS_CAPTURE_CONTENT set to false, the Input / Output tab says so and the timings, tokens and cost still show.

Set it up

  1. Install the SDK and the framework. The base package is enough, and the claude CLI must be installed and signed in. The Claude Agent SDK page covers setup in full.
pip install glassflow-rius claude-agent-sdk
  1. Wrap each task in observe with the AGENT kind, and wrap the query() loop in a generation. Pass the task as input, and call set_output with the collected answer.
import rius from claude_agent_sdk import ( AssistantMessage, ClaudeAgentOptions, ResultMessage, TextBlock, query, ) from rius import SpanKind rius.init(api_key="ri_...", service_name="my-agent") MODEL = "claude-haiku-4-5" @rius.observe(name="handle-task", kind=SpanKind.AGENT) async def handle_task(task: str) -> str: options = ClaudeAgentOptions(model=MODEL, max_turns=1) parts = [] with rius.start_as_current_generation( "claude_agent_turn", model=MODEL, provider="anthropic", input=task ) as gen: async for message in query(prompt=task, options=options): if isinstance(message, AssistantMessage): parts.extend( b.text for b in message.content if isinstance(b, TextBlock) ) elif isinstance(message, ResultMessage): usage = message.usage or {} gen.set_usage( input_tokens=usage.get("input_tokens"), output_tokens=usage.get("output_tokens"), cache_read_input_tokens=usage.get("cache_read_input_tokens"), # Anthropic's payload still calls the write count "cache creation" cache_write_input_tokens=usage.get("cache_creation_input_tokens"), ) models = list((message.model_usage or {}).keys()) if models: gen.set_response_model(models[0]) answer = "".join(parts) gen.set_output(answer) return answer
  1. Use a full model id such as claude-haiku-4-5, not an alias such as haiku, in both the CLI option and the generation. An alias gives a generation with no cost. Keep provider="anthropic" so the cache counts are added to the input tokens for you.

  2. Run one task, open Traces and open the new trace. Select the claude_agent_turn span and choose the Input / Output tab to read the prompt and the answer. Raw shows the span exactly as ingested. See Exploring traces for the rest of the trace page.

What you get

  • The prompt and answer of every task on the generation span, beside the model, token counts and computed cost. The cost is a list-price estimate in US dollars.
  • One row per turn in the Spans tab. Choose LLM in the All kinds menu to list every turn across your tasks, and search by session ID to find one conversation.
  • Quick stepping. In the span panel, ]l and [l jump to the next and previous LLM span, and the tab you have open stays open as you step.
  • Conversations grouped as sessions. Scope each task with rius.session(), and use the SDK’s own session_id as the Rius session id if you resume conversations. The Session link in a trace header opens the spans of that session, so you can read the prompts of a whole conversation in order.
  • Clear status. A failed task shows on its root span, and the tree highlights the path from the root to the error.

This is the Monitor AI agents in production view applied to the Claude Agent SDK: one trace per task, with the prompt and answer on the model-call span.

When something else fits

  • If you need the runtime’s tool calls, sub-turns or file operations as their own spans, this setup does not record them. Add observe spans in your own code around the steps you control.
  • If your agent also calls models directly through a client library such as Anthropic or OpenAI, those calls are recorded automatically. The Integrations page lists what each library, framework and protocol captures.

Still stuck? Get help

Last updated on