Required session and agent attributes
When you wire up a less-managed setup, you want the exact values to pass, so every span lines up in one session and cost attributes to the right agent. This page is the complete list for the setup pages.
How much you pass depends on the scenario:
-
Managed harness and Strands/other frameworks on AgentCore Runtime: Runtime supplies the session and agent identity. You pass a session id on the invoke, and
aws.tenant.idonly if you want per-tenant cost. The user is set by AgentCore Runtime from the caller’s identity; you do not pass it. -
Self-hosted: you pass all the values below yourself. See Self-hosted compute.
-
Plain OpenTelemetry (non-ADOT) on AgentCore Runtime: Runtime still supplies the session and agent identity. Read the session id from
BedrockAgentCoreContext.get_session_id()or theX-Amzn-Bedrock-AgentCore-Runtime-Session-Idheader, add thetracecontext,xray,baggagepropagators, and copysession.id,aws.tenant.id, anduser.idonto the agent’s own spans as a self-hosted agent does.
On the invoke (agents on AgentCore Runtime)
| Value | How to pass it | Notes | Example |
|---|---|---|---|
|
Session id |
|
Minimum 33 characters. Generated if you leave it out. Use the same id for every call in one conversation. |
|
|
Tenant |
|
Optional; only for per-tenant cost. Set it on every agent runtime and instance. The per-tenant cost figure is an estimate. |
|
|
User |
Set by AgentCore Runtime from the caller’s IAM principal or from incoming JWT claims (the role ARN that called |
You do not pass it, and |
|
import boto3 client = boto3.client("bedrock-agentcore", region_name="us-east-1") client.invoke_agent_runtime( agentRuntimeArn="<your agent runtime ARN>", runtimeSessionId="<at least 33 characters>", baggage="aws.tenant.id=<your tenant>", payload='{"prompt": "..."}', )
In baggage on every request (self-hosted agents)
A self-hosted agent passes these in OpenTelemetry baggage, so they travel with each call to an AgentCore tool:
| Value | Key | What it does | Example |
|---|---|---|---|
|
Calling agent id |
|
Charges the tool call to the agent that made it. Set it to the agent’s |
|
|
Session id |
|
Which conversation the call belongs to. |
|
|
Tenant |
|
For the Tenant filter. The per-tenant cost figure is an estimate. |
|
|
User |
|
For the User ID filter. |
|
Every call to an AgentCore tool must happen while these are set. Also copy session.id, aws.tenant.id, and user.id onto the agent’s own spans (at least its model-call spans), because values that are only passed along do not appear on the agent’s spans by themselves. See Self-hosted compute, Step 7.
On the agent’s own identity (self-hosted agents)
Set once as an environment variable:
OTEL_RESOURCE_ATTRIBUTES=cloud.resource_id=<stable ID, not containing :runtime/>,service.name=<agent name>,service.version=<version>
-
cloud.resource_id— the agent’s id. Must not contain:runtime/. -
service.name— the agent name the console shows. -
service.version— the agent version (shown, but does not split the agent into separate rows).
For example:
OTEL_RESOURCE_ATTRIBUTES=cloud.resource_id=arn:aws:eks:us-west-2:111122223333:cluster/my-agent,service.name=my_agent-AbCdEf1234,service.version=1
On each model-call span
Every model call needs a span that is marked CLIENT, with:
-
gen_ai.operation.nameset tochat,text_completion,generate_content, orembeddings, -
gen_ai.request.model— the model id, -
gen_ai.usage.input_tokensandgen_ai.usage.output_tokens.
Frameworks and their instrumentation produce this span; create it yourself only if you call a model from your own code.
Cost and usage attributes (for reference only)
You do not set these; they are listed so you can recognize them when you query spans.
-
Written by AWS X-Ray on priced spans:
aws.cost.total(for example0.000025),aws.cost.currency(USD), and on model-call spansaws.cost.inference.token.input(0.0000209) andaws.cost.inference.token.output(0.000121). -
Written by each AgentCore service as the basis for its price: Gateway
aws.agentcore.gateway.api_invocations/.search_api(1/1); Memoryaws.agentcore.memory.ingest_bytes/.read_bytes/.retrievals(12288/36864/1); Runtime, Browser, and Code Interpreteraws.agentcore.compute.vcpu_hours/.gb_hours(for example0.0023093/0.0042392).
Each measured field has a companion .type field that names the price-list entry the field is billed under, for example aws.agentcore.gateway.api_invocations.type = USW2-Gateway:Consumption-based:API-Invocations (the leading code is the Region: USW2 is us-west-2). For the full list of .type values and more examples, see the following reference.
Notes
-
The tenant and user values are whatever your agent or caller passes. They are carried on the agent’s own spans and roll up into an estimate calculated from public list prices, which can differ from your AWS bill.
Attribute and header reference
This is one complete list of the attribute and header names, so you do not misspell a value that breaks attribution. Names are case-sensitive and must match exactly.
The Example values below are the kind you see on your own spans in the console; these attributes are not internal. Identifiers that would name a specific account or resource are shown with standard documentation placeholders (for example account 111122223333, role MyAgentCaller); your own spans carry your real values. In a price-list .type value, the leading code is the Region (for example USW2 is us-west-2 and USE1 is us-east-1).
Invoke parameters and headers
| Name | Where | Purpose | Example |
|---|---|---|---|
|
|
Invoke parameter / |
The session id. Minimum 33 characters. Reuse across one conversation. |
|
|
|
Invoke parameter / |
Carries |
|
|
User |
Set by AgentCore Runtime (not an invoke parameter you pass) |
The user, taken from the caller’s IAM principal or incoming JWT claims (the role ARN that called |
|
Identity you set (self-hosted agents)
Set once in OTEL_RESOURCE_ATTRIBUTES:
| Attribute | Purpose | Example |
|---|---|---|
|
|
The agent’s id. Must not contain |
|
|
|
The agent name the console shows. |
|
|
|
The agent version. |
|
Values passed in baggage
| Key | Purpose | Example |
|---|---|---|
|
|
The conversation the call belongs to. |
|
|
|
The calling agent’s id, so a tool call is charged to it (self-hosted). Set it to the agent’s |
|
|
|
Tenant filter. The per-tenant cost figure is an estimate; the value is whatever you pass. |
|
|
|
User ID filter. |
|
Model-call span fields
| Field | Purpose | Example |
|---|---|---|
|
span kind |
Marks the call as an outgoing model call. |
|
|
|
One of |
|
|
|
The model id. |
|
|
|
Input (prompt) tokens. |
|
|
|
Output (completion) tokens. |
|
Environment variables (setup)
| Variable | Purpose |
|---|---|
|
|
Sets the agent identity (self-hosted). |
|
|
Lists baggage keys to copy onto spans, for example |
|
|
Avoids double-counted tokens when pairing Traceloop with Bedrock ( |
|
|
For a plain-OpenTelemetry (non-ADOT) agent on AgentCore Runtime, adds the AWS X-Ray trace format ( |
Cost and usage attributes (read-only, written for you)
You do not set these; they appear on spans.
| Attribute | Written by | On | Example |
|---|---|---|---|
|
|
Each AgentCore service |
That service’s spans |
|
|
|
AWS X-Ray |
Every priced span |
|
|
|
AWS X-Ray |
Every priced span |
|
|
|
AWS X-Ray |
Model-call spans |
|
|
|
AWS X-Ray |
Model-call spans |
|
|
|
Gateway, Memory, Browser, Code Interpreter |
Tool spans (the agent that made the call) |
|
|
|
Gateway |
Gateway spans |
|
|
|
Memory |
Memory spans |
|
|
|
Runtime, Browser, Code Interpreter |
Compute spans |
|
On a model-call span, aws.cost.total is the sum of the input and output token costs, for example 0.0001419
USD.
Each aws.agentcore.* measured field has a companion .type field (for example aws.agentcore.gateway.api_invocations.type) that names the price-list entry the field is billed under. The leading code in a .type value is the Region (USW2 is us-west-2, USE1 is us-east-1):
| Measured field |
.type example (us-west-2) |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Two Gateway fields are defined but have not been observed on a real span, so no example value is available: aws.agentcore.gateway.web_search_queries and aws.agentcore.gateway.vpc_bytes.