View a markdown version of this page

Required session and agent attributes - Amazon Bedrock AgentCore

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.id only 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 the X-Amzn-Bedrock-AgentCore-Runtime-Session-Id header, add the tracecontext,xray,baggage propagators, and copy session.id, aws.tenant.id, and user.id onto 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

runtimeSessionId on the invoke (header X-Amzn-Bedrock-AgentCore-Runtime-Session-Id)

Minimum 33 characters. Generated if you leave it out. Use the same id for every call in one conversation.

my-session-0001-a1b2c3d4e5f6a7b8c

Tenant

baggage="aws.tenant.id=<tenant>" on the invoke

Optional; only for per-tenant cost. Set it on every agent runtime and instance. The per-tenant cost figure is an estimate.

aws.tenant.id=tenant-a

User

Set by AgentCore Runtime from the caller’s IAM principal or from incoming JWT claims (the role ARN that called InvokeAgentRuntime)

You do not pass it, and runtimeUserId does not set it.

arn:aws:iam::111122223333:role/MyAgentCaller

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

aws.client.cloud.resource_id

Charges the tool call to the agent that made it. Set it to the agent’s cloud.resource_id (Step 4 of the self-hosted setup).

arn:aws:eks:us-west-2:111122223333:cluster/my-agent

Session id

session.id

Which conversation the call belongs to.

my-session-0001-a1b2c3d4e5f6a7b8c

Tenant

aws.tenant.id

For the Tenant filter. The per-tenant cost figure is an estimate.

tenant-a

User

user.id

For the User ID filter.

arn:aws:iam::111122223333:role/MyAgentCaller

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.name set to chat, text_completion, generate_content, or embeddings,

  • gen_ai.request.model — the model id,

  • gen_ai.usage.input_tokens and gen_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 example 0.000025), aws.cost.currency (USD), and on model-call spans aws.cost.inference.token.input (0.0000209) and aws.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); Memory aws.agentcore.memory.ingest_bytes / .read_bytes / .retrievals (12288 / 36864 / 1); Runtime, Browser, and Code Interpreter aws.agentcore.compute.vcpu_hours / .gb_hours (for example 0.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

runtimeSessionId

Invoke parameter / X-Amzn-Bedrock-AgentCore-Runtime-Session-Id header

The session id. Minimum 33 characters. Reuse across one conversation.

my-session-0001-a1b2c3d4e5f6a7b8c

baggage

Invoke parameter / baggage header

Carries aws.tenant.id (and other baggage entries).

aws.tenant.id=tenant-a

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 InvokeAgentRuntime). You do not pass it, and runtimeUserId does not set it.

arn:aws:iam::111122223333:role/MyAgentCaller

Identity you set (self-hosted agents)

Set once in OTEL_RESOURCE_ATTRIBUTES:

Attribute Purpose Example

cloud.resource_id

The agent’s id. Must not contain :runtime/.

arn:aws:eks:us-west-2:111122223333:cluster/my-agent

service.name

The agent name the console shows.

my_agent-AbCdEf1234

service.version

The agent version.

1

Values passed in baggage

Key Purpose Example

session.id

The conversation the call belongs to.

my-session-0001-a1b2c3d4e5f6a7b8c

aws.client.cloud.resource_id

The calling agent’s id, so a tool call is charged to it (self-hosted). Set it to the agent’s cloud.resource_id.

arn:aws:eks:us-west-2:111122223333:cluster/my-agent

aws.tenant.id

Tenant filter. The per-tenant cost figure is an estimate; the value is whatever you pass.

tenant-a

user.id

User ID filter.

arn:aws:iam::111122223333:role/MyAgentCaller

Model-call span fields

Field Purpose Example

span kind CLIENT

Marks the call as an outgoing model call.

CLIENT

gen_ai.operation.name

One of chat, text_completion, generate_content, embeddings.

chat

gen_ai.request.model

The model id.

us.anthropic.claude-haiku-4-5-20251001-v1:0

gen_ai.usage.input_tokens

Input (prompt) tokens.

1536

gen_ai.usage.output_tokens

Output (completion) tokens.

842

Environment variables (setup)

Variable Purpose

OTEL_RESOURCE_ATTRIBUTES

Sets the agent identity (self-hosted).

OTEL_BAGGAGE_SPAN_ATTRIBUTE_KEYS

Lists baggage keys to copy onto spans, for example aws.tenant.id (ADOT 0.16.0 or later). session.id is copied automatically when agent observability is enabled; the tenant is not, so set this variable to get per-tenant cost.

OTEL_PYTHON_DISABLED_INSTRUMENTATIONS

Avoids double-counted tokens when pairing Traceloop with Bedrock (botocore, or bedrock on ADOT 0.23.0+).

OTEL_PROPAGATORS

For a plain-OpenTelemetry (non-ADOT) agent on AgentCore Runtime, adds the AWS X-Ray trace format (tracecontext,xray,baggage) so the agent’s spans link to the Runtime trace.

Cost and usage attributes (read-only, written for you)

You do not set these; they appear on spans.

Attribute Written by On Example

aws.resource.type

Each AgentCore service

That service’s spans

AWS::BedrockAgentCore::Gateway

aws.cost.total

AWS X-Ray

Every priced span

0.000025

aws.cost.currency

AWS X-Ray

Every priced span

USD

aws.cost.inference.token.input

AWS X-Ray

Model-call spans

0.0000209

aws.cost.inference.token.output

AWS X-Ray

Model-call spans

0.000121

aws.client.cloud.resource_id

Gateway, Memory, Browser, Code Interpreter

Tool spans (the agent that made the call)

arn:aws:bedrock-agentcore:us-west-2:111122223333:runtime/my_agent-AbCdEf1234/runtime-endpoint/DEFAULT:DEFAULT

aws.agentcore.gateway.api_invocations / .search_api (+ .type)

Gateway

Gateway spans

1

aws.agentcore.memory.ingest_bytes / .read_bytes / .retrievals (+ .type)

Memory

Memory spans

12288 / 36864 / 1

aws.agentcore.compute.vcpu_hours / .gb_hours (+ .type)

Runtime, Browser, Code Interpreter

Compute spans

0.0023093 / 0.0042392

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)

aws.agentcore.compute.vcpu_hours (Runtime)

USW2-Runtime:Consumption-based:vCPU-v2

aws.agentcore.compute.gb_hours (Runtime)

USW2-Runtime:Consumption-based:Memory-v2

aws.agentcore.gateway.api_invocations

USW2-Gateway:Consumption-based:API-Invocations

aws.agentcore.gateway.search_api

USW2-Gateway:Consumption-based:Search-API

aws.agentcore.memory.ingest_bytes

USW2-Memory:Consumption-based:STM-Ingest

aws.agentcore.memory.read_bytes

USW2-Memory:Consumption-based:STM-Read

aws.agentcore.memory.retrievals

USW2-Memory:Consumption-based:Long-Term-Memory-Retrieval

aws.agentcore.compute.vcpu_hours (Code Interpreter)

USW2-CodeInterpreter:Consumption-based:vCPU

aws.agentcore.compute.gb_hours (Code Interpreter)

USW2-CodeInterpreter:Consumption-based:Memory

aws.agentcore.compute.vcpu_hours (Browser)

USW2-BrowserTool:Consumption-based:vCPU

aws.agentcore.compute.gb_hours (Browser)

USW2-BrowserTool:Consumption-based:Memory

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.