

# 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](acv-how-cost-is-attributed.md).

## Open a session and read its cost
<a name="_open_a_session_and_read_its_cost"></a>

 **To open a session and read its cost (console)** 

1. Open the [AgentCore observability](https://console.aws.amazon.com/bedrock-agentcore/observability) page and use the **Agent** selector to scope to the agent you are interested in.

1. 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.

1. 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 name="_what_a_session_total_includes"></a>

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](acv-cost-coverage-by-primitive.md).

## Session, trace, and span levels
<a name="_session_trace_and_span_levels"></a>

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](#acv-drill-from-spike-to-span).

## Why compute is measured for each session
<a name="_why_compute_is_measured_for_each_session"></a>

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
<a name="acv-break-down-session-cost"></a>

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
<a name="_open_the_per_component_breakdown"></a>

 **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.

1. 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.

1. 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](#acv-drill-from-spike-to-span)).

### Read the breakdown
<a name="_read_the_breakdown"></a>

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](acv-cost-coverage-by-primitive.md).

### Roll the breakdown up across the fleet
<a name="_roll_the_breakdown_up_across_the_fleet"></a>

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
<a name="_use_the_breakdown_to_decide_where_to_optimize"></a>
+ 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](acv-read-cost-against-outcomes.md).
+ 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
<a name="acv-drill-from-spike-to-span"></a>

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
<a name="_start_from_a_ranked_agent_or_an_outlier_session"></a>

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](acv-find-most-expensive-agents-and-sessions.md).

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

### Drill session to trace to span
<a name="_drill_session_to_trace_to_span"></a>

 **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.

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

1. 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 name="_recognize_a_driver"></a>

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
<a name="_confirm_a_fix"></a>

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](acv-how-agent-cost-is-calculated.md#acv-principles-behind-the-figures).