Submits an agent’s execution traces so that AWS Context can extract reusable knowledge and skills from them. Call it when an agent finishes a task or session that is worth learning from. In agentContextArns , name the agent contexts that the traces are about. AWS Context analyzes the traces for each of them.
Each traceDocuments entry is one raw trace document in the trace schema that format selects. You can send 1–100 documents per call. Each document can be up to 5 MiB before encoding. If you use an AWS SDK, pass each document’s raw bytes. If you call PutTrace through the agent context’s MCP server or another JSON client, send each document as a base64-encoded string. To send a larger trace, split it across calls that share a sessionId .
sessionIdgroups related calls into one session. If you omit it, AWS Context generates one and returns it in the response so that you can reuse it.
Each agent context can hold up to 100,000 trace documents. If a request would exceed this quota, it fails with ServiceQuotaExceededException , and AWS Context stores no documents. If a request fails for any other reason, AWS Context might have stored some of its documents. To store the rest without duplicates, retry with the same clientToken .
See also: AWS API Documentation
put-trace
[--session-id <value>]
[--client-token <value>]
--format <value>
--trace-documents <value>
--agent-context-arns <value>
[--trace-metadata <value>]
[--access-control-config <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
[--cli-binary-format <value>]
[--no-cli-pager]
[--cli-auto-prompt]
[--no-cli-auto-prompt]
[--cli-error-format <value>]
[--help]
--session-id (string)
The agent session this trace belongs to and the grouping key: multiple PutTrace calls with the same
sessionIdare one session. Optional. If you omit it, the service generates one and returns it in the response. It is not thetraceId: an OTLP batch carries many trace_ids under one session.Constraints:
- min:
1- max:
1024- pattern:
[a-zA-Z0-9][a-zA-Z0-9_-]*
--client-token (string)
Makes the call idempotent. A retry with the same token and the same request returns the same
sessionIdand does not write the traces again. Reusing the token fails withValidationExceptionif the request is different, or if another caller reuses it whenaccessControlConfignames no entries. A token is honored for 8 hours after its first use. WhenaccessControlConfignames no entries and the caller’s end user cannot be resolved at the time of the retry, the retry fails withValidationExceptioneven if the first attempt stored traces. To complete them, resend with explicit entries under a new token.Constraints:
- min:
1- max:
64- pattern:
[\x21-\x7E]+
--format (string) [required]
The format of the documents in
traceDocuments. Valid values:
OTEL- OpenTelemetry traces in OTLP/JSON.ANTHROPIC- Claude Code session logs, one log line per document.BEDROCK_CONVERSE- Amazon Bedrock Converse messages, one message (roleandcontent) per document, in conversation order.KIRO- Kiro IDE or Kiro CLI session logs.Possible values:
OTELANTHROPICBEDROCK_CONVERSEKIRO
--trace-documents (list) [required]
The raw trace documents, in the trace schema that
formatselects. You can send 1–100 documents per call, and each document can be up to 5 MiB (5,242,880 bytes) before encoding. If you use an AWS SDK, pass each document’s raw bytes. If you call PutTrace through the agent context’s MCP server or another JSON client, send each document as a base64-encoded string.Constraints:
- min:
1- max:
100(blob)
One raw trace document, up to 5 MiB (5,242,880 bytes) before encoding. Through the MCP server or another JSON client, send it as a base64-encoded string. If you use OpenTelemetry, split a large trace into multiple spans across
traceDocumentsand link them with your span metadata, instead of sending one oversized document.Constraints:
- min:
1- max:
5242880
Syntax:
blob blob ...
--agent-context-arns (list) [required]
The ARNs of the agent contexts that the traces are about: 1–10
agent-context/ARNs that name at most 5 distinct agent contexts, in this Region and partition, all in your account. If you name more, the request fails withValidationException. AWS Context authorizescontext:PutTraceonce for each agent context. If any authorization is denied, the whole call fails withAccessDeniedException, and nothing is stored. After authorization, if trace analysis is disabled for an agent context, the call fails withValidationException, and nothing is stored.Constraints:
- min:
1- max:
10(string)
The Amazon Resource Name (ARN) of an agent context. The ARN has the following parts:
- A partition:
aws,aws-cn, oraws-us-gov.- A Region of up to 32 characters.
- An account of exactly 12 digits.
- The resource path
agent-context/.- An ID of lowercase letters and digits in single-hyphen-separated runs.
This matches the public agent context ID format.
Constraints:
- min:
1- max:
180- pattern:
arn:(aws|aws-cn|aws-us-gov):context:[a-z0-9\-]{1,32}:\d{12}:agent-context/[a-z0-9]+(-[a-z0-9]+)*
Syntax:
"string" "string" ...
--trace-metadata (map)
Client-supplied key-value pairs, stored with the traces as-is. The key
analysisModeis reserved. A request that sets it fails withAccessDeniedException.Constraints:
- min:
0- max:
50key -> (string)
Constraints:
- min:
1- max:
128value -> (string)
Constraints:
- min:
0- max:
1024
Shorthand Syntax:
KeyName1=string,KeyName2=string
JSON Syntax:
{"string": "string"
...}
--access-control-config (structure)
The principals who can see the insights that AWS Context generates from the traces. If you provide entries, the caller is not included unless an entry names it.
If you provide no entries (
accessControlConfigabsent, oraccessControlListabsent or empty), only the end user that the caller’s trusted identity propagation session names can see the insights. If the session names no end user, or there is no session, the call fails withValidationExceptionand stores nothing. In that case, name the principals, or sendALLOWfor*so that every reader of the agent contexts can see the insights.An entry other than
*withoutprincipalType, aprincipalIdthat is not valid Unicode, or entries that total more than 65,536 bytes of UTF-8 are rejected withValidationException. AWS Context stores principal IDs as given and does not verify them against a directory. A session’s access control is the union of its traces’ entries. A call that would take that union over 100 entries, or over 65,536 bytes of UTF-8, fails withValidationExceptionand stores nothing.accessControlList -> (list)
Entries, each allowing or denying one principal.
Constraints:
- min:
0- max:
100(structure)
Allows or denies one end user or group, or every reader (
*).access -> (string) [required]
Specifies whether the principal can see the information.
Valid values:
ALLOW- Access is allowed.DENY- Access is denied.Possible values:
ALLOWDENYprincipalId -> (string) [required]
The principal’s opaque user or group ID, or
*for every reader authorized on the resource.Constraints:
- min:
1- max:
1024- pattern:
.*\A[^\s`]+\z.*principalType -> (string)
Specifies whether
principalIdnames a user or a group. Required unlessprincipalIdis*, where it is ignored.Valid values:
USER- An end user.GROUP- A group of end users.Possible values:
USERGROUP
Shorthand Syntax:
accessControlList=[{access=string,principalId=string,principalType=string},{access=string,principalId=string,principalType=string}]
JSON Syntax:
{
"accessControlList": [
{
"access": "ALLOW"|"DENY",
"principalId": "string",
"principalType": "USER"|"GROUP"
}
...
]
}
--cli-input-json | --cli-input-yaml (string)
Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, those values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally. This may not be specified along with --cli-input-yaml.
--generate-cli-skeleton (string)
Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input, prints a sample input JSON that can be used as an argument for --cli-input-json. Similarly, if provided yaml-input it will print a sample input YAML that can be used with --cli-input-yaml. If provided with the value output, it validates the command inputs and returns a sample output JSON for that command. The generated JSON skeleton is not stable between versions of the AWS CLI and there are no backwards compatibility guarantees in the JSON skeleton generated.
--debug (boolean)
Turn on debug logging.
--endpoint-url (string)
Override command’s default URL with the given URL.
--no-verify-ssl (boolean)
By default, the AWS CLI uses SSL when communicating with AWS services. For each SSL connection, the AWS CLI will verify SSL certificates. This option overrides the default behavior of verifying SSL certificates.
--no-paginate (boolean)
Disable automatic pagination. If automatic pagination is disabled, the AWS CLI will only make one call, for the first page of results.
--output (string)
The formatting style for command output.
--query (string)
A JMESPath query to use in filtering the response data.
--profile (string)
Use a specific profile from your credential file.
--region (string)
The region to use. Overrides config/env settings.
--version (string)
Display the version of this tool.
--color (string)
Turn on/off color output.
--no-sign-request (boolean)
Do not sign requests. Credentials will not be loaded if this argument is provided.
--ca-bundle (string)
The CA certificate bundle to use when verifying SSL certificates. Overrides config/env settings.
--cli-read-timeout (int)
The maximum socket read time in seconds. If the value is set to 0, the socket read will be blocking and not timeout. The default value is 60 seconds.
--cli-connect-timeout (int)
The maximum socket connect time in seconds. If the value is set to 0, the socket connect will be blocking and not timeout. The default value is 60 seconds.
--cli-binary-format (string)
The formatting style to be used for binary blobs. The default format is base64. The base64 format expects binary blobs to be provided as a base64 encoded string. The raw-in-base64-out format preserves compatibility with AWS CLI V1 behavior and binary values must be passed literally. When providing contents from a file that map to a binary blob fileb:// will always be treated as binary and use the file contents directly regardless of the cli-binary-format setting. When using file:// the file contents will need to properly formatted for the configured cli-binary-format.
--no-cli-pager (boolean)
Disable cli pager for output.
--cli-auto-prompt (boolean)
Automatically prompt for CLI input parameters.
--no-cli-auto-prompt (boolean)
Disable automatically prompt for CLI input parameters.
--cli-error-format (string)
The formatting style for error output. By default, errors are displayed in enhanced format.
--help (boolean)
Display help for the command/subcommand.
sessionId -> (string)
The session ID for the traces: the
sessionIdthat you specified, or one that AWS Context generated if you omitted it. A successful response means that AWS Context stored every document. A failed call might leave some documents stored. To store the rest without duplicates, retry with the sameclientToken.Constraints:
- min:
1- max:
1024- pattern:
[a-zA-Z0-9][a-zA-Z0-9_-]*