View a markdown version of this page

Observability and cost controls - Amazon Bedrock AgentCore

Observability and cost controls

This page covers monitoring your harness, controlling execution costs, and managing resource tags.

Observability

Every harness invocation automatically generates traces, logs, and metrics through AgentCore Observability in CloudWatch. Model calls, tool invocations, memory operations, shell commands: each step appears with timing and payload details. No extra configuration. Traces are available from the first invocation.

Example
AgentCore CLI
# Stream logs agentcore logs --harness research-agent # Filter agentcore logs --harness research-agent --since 1h --level error # List recent traces agentcore traces list --harness research-agent # Get a specific trace agentcore traces get <trace-id> --harness research-agent
AWS CLI/boto3

Traces, logs, and metrics flow to CloudWatch through the harness execution role. View them in the AgentCore Observability dashboard, or query programmatically through the CloudWatch Logs and X-Ray APIs.

Before you see traces, enable Transaction Search in CloudWatch (one-time per account). See AgentCore Observability getting started for setup details.

Learn more: Observability overview · metrics · telemetry

Control cost with limits

Set hard caps so a runaway agent can’t burn through resources:

  • maxIterations - reasoning/action cycles per invocation. Default 75.

  • timeoutSeconds - wall-clock timeout for a single invocation. Default 3600.

  • maxTokens - token budget per invocation. Default N/A.

  • idleRuntimeSessionTimeout - how long an idle microVM stays warm. Default 900.

  • maxLifetime - maximum lifetime of a microVM session. Default 28800.

All limits are optional; omit them to use service defaults.

Example
AgentCore CLI

Set defaults:

agentcore add harness --name bounded-agent \ --max-iterations 50 --timeout 1800 --max-tokens 8192 \ --truncation-strategy sliding_window \ --idle-timeout 600 --max-lifetime 14400 agentcore deploy

The --truncation-strategy flag accepts sliding_window or summarization. The --idle-timeout and --max-lifetime flags set lifecycle limits in seconds.

Override on a single call:

agentcore invoke --harness bounded-agent --max-iterations 20 --harness-timeout 600 \ "Quick lookup: what's the weather in Seattle?"
AWS CLI/boto3
aws bedrock-agentcore-control update-harness \ --harness-id "MyHarness-UuFdkQoXSL" \ --max-iterations 50 \ --timeout-seconds 1800 \ --max-tokens 8192

Or override on a single invocation by passing maxIterations, timeoutSeconds, or maxTokens in invoke_harness.

Tags

Apply tags to your harness for cost allocation and access control.

Example
AgentCore CLI

Set tags in harness.json:

{ "tags": { "team": "platform", "environment": "staging" } }

Run agentcore deploy to apply.

AWS CLI/boto3
aws bedrock-agentcore-control create-harness \ --harness-name "MyHarness" \ --execution-role-arn "arn:aws:iam::123456789012:role/MyHarnessRole" \ --tags '{"team": "platform", "environment": "staging"}'

Tags flow through to deployed CloudFormation resources.