View a markdown version of this page

Trace sources - AWS Context

Trace sources

AWS Context learns from two sources of traces: the agents built into AWS Context, and the traces that your own agents submit with the PutTrace API.

Your agents can submit traces in the following formats:

  • OTEL – OpenTelemetry traces in OTLP/JSON.

  • ANTHROPIC – Claude Code session logs.

  • BEDROCK_CONVERSE – Amazon Bedrock Converse messages.

  • KIRO – Kiro IDE or Kiro CLI session logs.

BEDROCK_CONVERSE also works as a general format. Any conversation works in this format if each message is a JSON object with a role and a content field, sent as one trace document per message. The role is user or assistant, and the content is a plain string or a list of text blocks. For example, a conversation of one user turn and one assistant turn is the following two trace documents, shown one per line:

{"role": "user", "content": "How many units can we still sell from Atlanta?"} {"role": "assistant", "content": "48,510 units."}

AWS Context agent traces

Trace analysis can learn from the agents built into AWS Context, such as the Context retrieval agent that answers your agentic retrieval requests (AgenticRetrieve and AgenticRetrieveStream). AWS Context records these traces itself, so your agents don’t submit anything.

AWS Context records an agent trace for a request when all of the following are true:

To group the traces of related requests into one session, set the same sessionId on each request (see Sessions).

Learnings from these traces are proposed like any other change. They pass through your curation policies before any agent sees them (see Review proposals and quality signals).

Traces from your agents

Your agent submits its own execution traces with the PutTrace API so that trace analysis can learn from them. Each request carries one or more trace documents, such as the records of the agent’s session log. The request names the target Agent Contexts in agentContextArns and declares the format of the trace documents in format, which is one of the supported trace formats. A request without a user identity must also name the readers of its learnings in accessControlConfig (see Who can see learnings from your traces).

Turn on trace analysis for each Agent Context that the request names (see Turn on trace analysis). Submitting traces doesn’t change an Agent Context directly. The learnings from the feedback loop arrive as proposed changes, and your curation policies govern them like any other change.

For more information about the request fields, see PutTrace in the AWS Context API Reference.

The following example submits two trace documents of a Kiro session and lets every reader of the Agent Context see the learnings.

aws context put-trace --cli-input-json '{ "agentContextArns": ["arn:aws:context:us-east-1:111122223333:agent-context/ac-EXAMPLE11111"], "format": "KIRO", "sessionId": "my-session-1", "traceDocuments": ["<base64-encoded-document-1>", "<base64-encoded-document-2>"], "accessControlConfig": { "accessControlList": [ { "access": "ALLOW", "principalId": "*" } ] } }'

Replace the Region, the account ID, the Agent Context ID, the session ID, and the two documents with your own values.