AWS Builder Center

Making your Amazon Connect AI agent observable in Amazon CloudWatch Omni

I connected an Amazon Connect AI agent to reservation APIs through Amazon Bedrock AgentCore Gateway across three AWS accounts and tried to see the whole conversation in CloudWatch Omni. Here's what worked out of the box, what didn't, and the small amount of code I used to close the gap.

AI agents in the contact center do a lot more than answer questions these days. They look up a guest's hotel reservation, check whether a room is available, and change the dates on a booking. That's great, until the agent does something you didn't expect. Then you want answers fast. What did the agent decide? Which systems did it call? And where did the time go?
I wanted to see how well we can answer those questions in a realistic enterprise setup, so I built one and tested it end to end.

What I built

The guest talks to an Amazon Connect AI agent. When the agent needs to look something up or make a change, it calls reservation APIs as tools through Amazon Bedrock AgentCore Gateway. To keep it realistic, I put Connect, AgentCore and the reservation APIs in three separate AWS accounts, which is how a lot of larger organizations split things up. My goal was simple: see the whole conversation in Amazon CloudWatch Omni, in one place.

What worked right away

The agent experience worked well. The Connect AI agent found its tools and handled real requests, like finding a reservation, checking availability and updating the booking.
AgentCore Gateway and the reservation APIs showed up in CloudWatch Omni on their own, as one connected trace. Getting the Omni space set up and data flowing into it only took a few minutes.

What didn't work out of the box

The biggest surprise was that the Connect AI agent's own traces stay inside Connect. Connect records a lot of useful detail about every turn, including the agent's reasoning, its model calls and which tools it picked. You can look at all of that in Connect, but none of it gets sent to CloudWatch Omni.
Connect also doesn't pass trace context along when it calls a tool. As a result, the agent's activity and the backend's activity show up as two separate traces that don't know about each other.
And connecting Connect to a gateway in a different account took an extra step. I solved that by putting a small gateway in the Connect account that simply forwards calls to the central one.

How I filled the gap

I added two small pieces: a shared conversation ID and a lightweight bridge.

Step 1: Pass the conversation ID into every tool call

Connect AI agents let you override tool inputs with Connect system variables. I added an optional  connect_session_id  field to each reservation tool and told Connect to fill it in automatically. The model never sees it or has to guess it.
tool_config = {
"toolName": "get_reservation",
"toolType": "MODEL_CONTEXT_PROTOCOL",
"toolId": f"gateway_{gateway_id}__hub___reservations___get_reservation",
"overrideInputValues": [
{"jsonPath": "$.connect_session_id",
"value": {"constant": {"type": "STRING", "value": "{{$.sessionId}}"}}},
{"jsonPath": "$.connect_contact_id",
"value": {"constant": {"type": "STRING", "value": "{{$.contactId}}"}}},
],
}
On the backend, the reservation API pulls those IDs out before doing its work and tags its own trace with them:
from aws_xray_sdk.core import xray_recorder

def lambda_handler(event, context):
session_id = event.pop("connect_session_id", None)
contact_id = event.pop("connect_contact_id", None)

with xray_recorder.in_subsegment("tool get_reservation") as span:
if session_id:
span.put_annotation("session_id", session_id)
if contact_id:
span.put_annotation("connect_contact_id", contact_id)
return get_reservation(event)

Step 2: Bridge Connect's traces into Omni

Connect writes an event to its logs whenever a conversation turn finishes. A small Lambda function listens for those events, reads the turn's details with the  ListSpans  API, and translates each step into the OpenTelemetry format that CloudWatch Omni understands.
OPERATION = {"invoke_agent": "invoke_agent", "inference": "chat", "execute_tool": "execute_tool"}

def to_otel(span, session_id):
attrs = span["attributes"]
op = OPERATION[span["spanName"]]
otel = {
"gen_ai.operation.name": op,
"gen_ai.agent.name": attrs["aiAgentName"],
"session.id": session_id,
"session_id": session_id, # same key the backend uses, so one query finds both
}
if op == "chat":
otel["gen_ai.request.model"] = attrs.get("requestModel")
otel["gen_ai.usage.input_tokens"] = attrs.get("usageInputTokens")
otel["gen_ai.usage.output_tokens"] = attrs.get("usageOutputTokens")
return otel
Then it sends the spans to the CloudWatch OTLP endpoint in the Omni account, signed with regular AWS credentials:
import json
import urllib.request

from botocore.auth import SigV4Auth
from botocore.awsrequest import AWSRequest

def send_spans(otlp_doc, credentials, region):
url = f"https://xray.{region}.amazonaws.com/v1/traces"
body = json.dumps(otlp_doc).encode()
request = AWSRequest("POST", url, data=body, headers={"Content-Type": "application/json"})
SigV4Auth(credentials, "xray", region).add_auth(request)
urllib.request.urlopen(
urllib.request.Request(url, data=body, headers=dict(request.headers), method="POST"))
With both pieces in place, you can search Omni for a single session ID and get the full story in one view: what the guest asked, what the agent decided, which API it called and how long each step took.
connect-ai-agent/reservations-agent invoke_agent session_id=3c09…
connect-ai-agent/reservations-agent chat claude-haiku-4-5 1385/163 tok session_id=3c09…
connect-ai-agent/reservations-agent execute_tool get_reservation session_id=3c09…
connect-ai-agent/reservations-agent chat claude-haiku-4-5 1629/80 tok session_id=3c09…
reservations-api tool get_reservation session_id=3c09…

What I took away from it

This is doable today with a small amount of glue code, and the visibility is worth it, especially when you're testing and tuning an agent. I'd still treat the bridge as a stopgap, though. If Connect AI agents exported their traces natively, you wouldn't need it, and I've shared that feedback.
One more tip: if you're working across multiple accounts, decide early where your observability will live and how the data will get there. It saves a lot of rework later.

What's coming

I'm turning this into a reusable code repository. It will deploy the whole multi-account setup with one command, run a quick test to confirm everything shows up in CloudWatch Omni, and clean up after itself when you're done. Stay tuned.
So far I've tested this with chat conversations, and voice is next on my list.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article