Agent Core
Overview
Amazon AgentCore is AWS’s managed runtime for deploying and scaling AI agents. Confident AI allows you to trace and evaluate AgentCore agents — in just a few lines of code.
The integration works via OpenTelemetry: instrument_agentcore() registers a AgentCoreSpanInterceptor and a ContextAwareSpanProcessor on the global TracerProvider. The interceptor translates AWS Bedrock / Strands / Traceloop OTel spans into Confident AI spans, and the processor ships them to Confident AI in real time.
Tracing Quickstart
For users in the EU region, please set the OTEL endpoint to the EU version as shown below:
Install Dependencies
Run the following command to install the required packages:
If you are using AgentCore with Strands, also install:
Instrument AgentCore
Call instrument_agentcore once at startup, before your agent runs. It attaches to the active OpenTelemetry TracerProvider (creating one if needed) and begins forwarding spans to Confident AI automatically.
instrument_agentcore is framework-agnostic. It works with any underlying agent framework that AgentCore supports — Strands, LangChain, LangGraph, and CrewAI are all detected automatically via OTel GenAI semantic conventions and Traceloop attributes.
Run your agent
Invoke your agent by executing the script:
You can directly view the traces on Confident AI by clicking on the link in the output printed in the console.
Advanced Usage
Logging threads
Threads are used to group related traces together, and are useful for chat apps, agents, or any multi-turn interactions. You can learn more about threads here. Pass the thread_id to instrument_agentcore.
If your agent framework already sets a session.id attribute on spans (Strands does this via trace_attributes={"session.id": ...}), AgentCore integration will automatically use it as the thread_id when none is explicitly provided.
Trace attributes
Other trace-level attributes can be passed to instrument_agentcore. All parameters are optional and apply to every trace produced while the instrumentation is active.
View Trace Attributes
Your Confident AI API key. Defaults to the CONFIDENT_API_KEY environment variable when omitted.
The name of the trace. Learn more.
Tags are string labels that help you group related traces. Learn more.
Attach any metadata to the trace. Learn more.
Supply the thread or conversation ID to view and evaluate conversations. Learn more.
Supply the user ID to enable user analytics. Learn more.
The turn ID for multi-turn conversations.
Associate this trace with a specific test case ID.
The name of the metric collection to use for online evals at the trace level.
The deployment environment. Accepted values: "production", "staging", "development", "testing". Defaults to "development".
Each attribute is optional, and works the same way as the native tracing features on Confident AI.
Logging prompts
If you are managing prompts on Confident AI and wish to log them, use next_llm_span to associate a Prompt with the next LLM span before invoking your agent.
Be sure to pull the prompt before logging it, otherwise the prompt will not be visible on Confident AI.
Re-configuring at runtime
instrument_agentcore is idempotent — calling it again on the same TracerProvider updates the trace-level settings in place without stacking additional processors. This lets you reconfigure per-request fields (such as thread_id or user_id) by calling instrument_agentcore again before each invocation.
Evals Usage
Online evals
You can run online evals on your AgentCore agent, which will run evaluations on all incoming traces on Confident AI’s servers. This approach is recommended if your agent is in production.
Create metric collection
Create a metric collection on Confident AI with the metrics you wish to use to evaluate your AgentCore agent.
Your metric collection must only contain metrics that evaluate the input and actual output of the component it is assigned to.
Run evals
Pass the metric_collection parameter to instrument_agentcore to run online evals at the trace level. For span-level evals, use update_current_span(metric_collection=...) inside your agent code.
We recommend creating separate metric collections for each component (trace, agent span, LLM span, tool span), since each requires its own evaluation criteria and metrics.
All incoming traces will now be evaluated using metrics from your metric collection.
You can view evals on Confident AI by clicking on the link in the output printed in the console.