How cost estimates are attributed to a session, agent, and fleet
When you trust a session or agent total, you want to know how the spans roll up, so you know when a number is solid and when it depends on setup.
Spans, traces, sessions
An agent emits small records of what it does, nested in three levels:
-
A span is a single action, such as one model call, one memory lookup, or one tool call.
-
A trace groups the spans of one turn.
-
A session groups the traces of one whole conversation or task.
So spans make up a trace, and traces make up a session.
How totals add up
Cost is recorded on each span. A total at any level is the sum of the span costs beneath it:
-
A session total is the sum of its spans' costs.
-
An agent total is the sum of its sessions.
-
A fleet total is the sum of its agents.
Each billable action is priced on exactly one span, so summing does not double count.
How a span is tied to an agent
-
An agent’s own span (its model calls and, on AgentCore Runtime, its Runtime span) names the agent in
cloud.resource_id. -
A tool span (Gateway, Memory, Browser, Code Interpreter) is charged to the agent that made the call, named in
aws.client.cloud.resource_id, copied from the request the agent sent. -
A model call with no
cloud.resource_idstill counts in the total, but under no agent.
This is why the identity values have to travel with each call. On the managed harness and on AgentCore Runtime, AgentCore creates and propagates them. On a self-hosted agent, you set the identity and pass the values in baggage; see Pass the required session and agent attributes.
Why identity must be identical across services
The rollup works only if every span in a session carries the same session.id, and every tool call carries the calling agent’s id. If one service uses a different value, that span cannot roll up with the rest, and its cost can land unattributed. Session, tenant, and user are recorded on the agent’s own spans; a tool span joins them by session.id.
Each action priced once
Because each billable action is priced on exactly one span, a session total does not double count, even when several spans describe the same model call. For a self-hosted agent, this depends on your instrumentation emitting the model call once; the AWS Distro for OpenTelemetry (ADOT) does this for you, which is why it is the supported telemetry source.