View a markdown version of this page

Investigate an agent session’s cost - Amazon Bedrock AgentCore

Investigate an agent session’s cost

When you are looking at a single agent run, you want the all-in cost of that session, so you can judge what one unit of work cost.

A session is one full unit of work, such as a whole conversation or task. It is made of traces, and each trace is made of spans. Cost is recorded on each span; a session’s cost is the sum of its spans' costs. See How cost estimates are attributed to a session, agent, and fleet.

Open a session and read its cost

To open a session and read its cost (console)

  1. Open the AgentCore observability page and use the Agent selector to scope to the agent you are interested in.

  2. Choose the Sessions view. Each session is a row; read its total in the Total cost column, and sort by that column to rank sessions.

  3. To see a session’s traces, choose its Session ID. The view switches to the Traces view filtered to that session (a Session = <session ID> filter token). There is no separate session page; the session total is the Total cost column in the Sessions view.

What a session total includes

A session total covers every priced action along the session’s path:

  • Model inference — the agent’s model calls, priced from input and output tokens (and cache tokens when present).

  • Runtime compute — the CPU and memory time of the machine that ran the agent.

  • Gateway — tool and API calls routed through AgentCore Gateway.

  • Memory — data written and lookups.

  • Browser and Code Interpreter — the CPU and memory time of each tool session.

  • Evaluations — online evaluations, when they are part of the session.

For exactly which dimensions are and are not covered, see Cost estimate coverage and limits.

Session, trace, and span levels

Each level carries its own estimated cost:

  • Session — the whole unit of work.

  • Trace — one turn within the session.

  • Span — one action, such as a single model call or tool call.

Opening a trace shows its spans, each with its own cost, so you can see which action inside a turn cost the most. See Drill from a spike to the span.

Why compute is measured for each session

The machine that runs an agent is billed for its whole lifetime, not for each turn, and it can stay warm between turns in a session. For that reason, Runtime compute cost is measured for the session as a whole and is not split below the session. A session’s compute appears as its own entry rather than spread across individual traces. Because this running-time cost is written after the machine stops, it arrives about 15 to 35 minutes after the session ends; until then the session shows only its model and per-call costs.

Break down the cost by component and model

When a session looks expensive, you want its cost split by Amazon Bedrock AgentCore component and by model inference, so you can see what the cost paid for.

Open the per-component breakdown

To open the per-component breakdown (console)

  1. In the Overview view, in the Trends and distribution section, choose the Cost graph tab to open the Estimated cost ($) panel.

  2. Set the Cost view toggle to By resource type. This view cannot be narrowed to a single session; use the Agent and Endpoint selectors to scope it to the agent you are investigating.

  3. Read the Cost ($) chart and the Cost by resource type list. For a single session’s components, open its traces and read each span’s cost in the trace details panel (see Drill from a spike to the span).

Read the breakdown

The breakdown separates model inference from the AgentCore components in the path:

  • Runtime — compute (CPU and memory time).

  • Memory — data written and lookups.

  • Gateway — tool and API calls.

  • Browser and Code Interpreter — tool-session compute.

  • Evaluations — online evaluations, when present in the session.

Model inference is usually the largest line, often by a wide margin. For what each component measures, see Cost estimate coverage and limits.

Roll the breakdown up across the fleet

The By resource type view shows the same split across your fleet, or across a scoped agent. The Cost by resource type list gives estimated cost per component - Inference, Memory, Runtime, Gateway, Browser tool, Code interpreter tool, and Evaluations - and each entry expands to its individual resources, so you can decide where optimization pays off.

Use the breakdown to decide where to optimize

  • If model inference dominates, look at prompt size, output length, and model choice. Compare two agent versions before shipping; see Read cost estimates against outcomes.

  • If Memory or Gateway is high, look at how often the agent writes to memory or calls tools.

  • If Runtime compute is high, look at long or idle sessions that keep a machine warm.

Drill from a spike to the span

When an agent gets more expensive, you want to trace the increase to the one action that caused it, so you can fix the root cause instead of guessing.

Because cost is recorded on each span, you can follow it down from an agent total to the single span behind a change.

Start from a ranked agent or an outlier session

  1. In the cost view, start from a high agent in the cost-by-agent ranking, or from an outlier session. See Find and filter your most expensive agents and sessions.

  2. Choose the session in the Sessions view (sorted by Total cost).

Drill session to trace to span

To drill from a session to a span (console)

  1. In the Traces view (filtered to the session), read the traces and sort by the Total cost column to rank them.

  2. Choose a Trace ID to open the trace details panel, which lists the trace’s spans.

  3. Select the highest-cost span to read its per-span cost in the panel (model, input and output tokens, and latency).

Each level, session to trace to span, carries its own figure, so you can see exactly where the cost concentrates.

Recognize a driver

A span view turns "this agent got more expensive this week" into a specific finding. For example, a retrieval span that pulled far more context than expected, or a model call with an unusually large input. The span shows what the action was, so you can act on it. Because cost sits on the same span as the latency and outcome data, you can also see whether the expensive action succeeded.

Confirm a fix

After you change the agent, run it again and compare the same session or agent before and after. The cost on the relevant span should drop. Historical figures are frozen, so an earlier session always shows the cost it had when it ran, which makes before-and-after comparison reliable. See Principles behind the figures.