Retrieves ranked context from an agent context for a natural-language question, in a single response. Send the question as a user message in messages and read the ranked retrievedContext . AWS Context searches and traverses the agent context for you until it has gathered enough context or reaches maxIterations . Prefer this over SearchAgentContext when finding the context needs more than one search or hop. To stream progress and receive a generated answer, use AgenticRetrieveStream.
See also: AWS API Documentation
agentic-retrieve
--agent-context-id <value>
--messages <value>
[--session-id <value>]
[--analysis-configuration <value>]
[--retrieval-configuration <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]
--agent-context-id (string) [required]
The agent context to retrieve from, by its ID or ARN.
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]+)*
--messages (list) [required]
The conversation, as an ordered list of turns. A single-question caller sends one user message. The list carries multi-turn history so a follow-up resolves against earlier turns.
Constraints:
- min:
1- max:
100(structure)
A single conversation turn.
role -> (string) [required]
The role of the participant that produced this turn. Valid values:
USER- The user asked or said this turn.ASSISTANT- The assistant answered in this turn.Possible values:
USERASSISTANTcontent -> (string) [required]
The turn’s text content.
Constraints:
- min:
1- max:
35000
Shorthand Syntax:
role=string,content=string ...
JSON Syntax:
[
{
"role": "USER"|"ASSISTANT",
"content": "string"
}
...
]
--session-id (string)
Optional. A key that you supply to group related calls, for example the turns of one conversation, for trace storage and analysis. Grouping is per account, across agent contexts, so use a value that is unique to each conversation.
Constraints:
- min:
1- max:
1024- pattern:
[a-zA-Z0-9][a-zA-Z0-9_-]*
--analysis-configuration (structure)
Optional controls for post-call analysis of the retrieval: whether its trace is stored for analysis.
emitTrace -> (string)
Specifies whether AWS Context stores this call’s agent trace for asynchronous analysis. Absent means ENABLED. A trace is stored only when the agent context’s traceAnalysisConfig also has status and includeContextAgentTraces ENABLED.
Possible values:
ENABLEDDISABLED
Shorthand Syntax:
emitTrace=string
JSON Syntax:
{
"emitTrace": "ENABLED"|"DISABLED"
}
--retrieval-configuration (structure)
Optional bounds and configuration for the agent loop.
maxIterations -> (integer)
The maximum number of agent turns, from 2 to 50. One turn is roughly one round of tool calls and their results. If you omit it, AWS Context uses 30. The minimum is 2, because the agent needs at least one planning turn and one acting turn.
Constraints:
- min:
2- max:
50
Shorthand Syntax:
maxIterations=integer
JSON Syntax:
{
"maxIterations": integer
}
--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.
retrievedContext -> (list)
The ranked, structured context that the agent assembled across all iterations, without duplicates. Always present. Each entry is a graph node, a graph edge, or a document.
Constraints:
- min:
0- max:
1000(structure)
One entity in the context that AgenticRetrieveStream returns: a graph node, a graph edge, or a document.
nodeId -> (string)
Identifier of the node. Set when this result is a node (one of nodeId, edgeId, or documentId).
Constraints:
- min:
0- max:
2048- pattern:
[\w\-\.#:@/%~]+edgeId -> (structure)
Identifier of the edge. Set when this result is an edge (one of nodeId, edgeId, or documentId).
from -> (string) [required]
The ID of the node where the edge starts.
Constraints:
- min:
0- max:
2048- pattern:
[\w\-\.#:@/%~]+to -> (string) [required]
The ID of the node where the edge ends.
Constraints:
- min:
0- max:
2048- pattern:
[\w\-\.#:@/%~]+documentId -> (string)
Identifier of the document. Set when this result is a document (one of nodeId, edgeId, or documentId).
Constraints:
- min:
1entityType -> (string) [required]
Specifies whether this result is a node, an edge, or a document. Valid values:
NODE- The result is a node.EDGE- The result is an edge.DOCUMENT- The result is a document.Possible values:
NODEEDGEDOCUMENTsummary -> (string)
Human-readable description or summary of the entity.
Constraints:
- min:
0- max:
1024content -> (structure)
The retrieved content of the entity.
byteContent -> (blob)
The binary content of the retrieved entity.text -> (string)
The text content of the retrieved entity.mimeType -> (string)
The Multipurpose Internet Mail Extensions (MIME) type of the retrieved content.
Constraints:
- min:
1- max:
256properties -> (map)
Arbitrary key-value properties stored on the entity.
Constraints:
- min:
0- max:
50key -> (string)
Constraints:
- min:
1- max:
128value -> (tagged union structure)
The value of a property on a node or an edge in an agent context. Exactly one member is set, and the member that is set determines the value’s type.
Note
This is a Tagged Union structure. Only one of the following top level keys can be set:stringValue,intValue,longValue,boolValue,floatValue,doubleValue,stringListValue,intListValue,longListValue,floatListValue,doubleListValue,boolListValue.stringValue -> (string)
A string value, up to 2,048 characters.
Constraints:
- min:
0- max:
2048intValue -> (integer)
A 32-bit signed integer value.longValue -> (long)
A 64-bit signed integer value.boolValue -> (boolean)
A Boolean value.floatValue -> (float)
A single-precision (32-bit) floating-point value.doubleValue -> (double)
A double-precision (64-bit) floating-point value.stringListValue -> (list)
A list of up to 1,000 string values, each up to 2,048 characters.
Constraints:
- min:
0- max:
1000(string)
Constraints:
- min:
0- max:
2048intListValue -> (list)
A list of up to 1,000 32-bit signed integer values.
Constraints:
- min:
0- max:
1000(integer)
longListValue -> (list)
A list of up to 1,000 64-bit signed integer values.
Constraints:
- min:
0- max:
1000(long)
floatListValue -> (list)
A list of up to 1,000 single-precision (32-bit) floating-point values.
Constraints:
- min:
0- max:
1000(float)
doubleListValue -> (list)
A list of up to 1,000 double-precision (64-bit) floating-point values.
Constraints:
- min:
0- max:
1000(double)
boolListValue -> (list)
A list of up to 1,000 Boolean values.
Constraints:
- min:
0- max:
1000(boolean)
answer -> (string)
The synthesized natural-language answer, when one was generated.
citations -> (list)
Maps spans of answer to the supporting entities, when an answer was generated.
Constraints:
- min:
0- max:
1000(structure)
Maps a span of the answer to the entities that support it. The span is answer[startIndex:endIndex].
startIndex -> (integer) [required]
The character offset inanswerwhere the cited span begins.endIndex -> (integer) [required]
The character offset inanswerwhere the cited span ends (exclusive).references -> (list) [required]
The entities in retrievedContext that support the span, referenced by identity.
Constraints:
- min:
0- max:
100(structure)
A reference by entity identity into retrievedContext (one of nodeId, edgeId, or documentId).
nodeId -> (string)
Identifier of the referenced node. Set when the reference is a node.
Constraints:
- min:
0- max:
2048- pattern:
[\w\-\.#:@/%~]+edgeId -> (structure)
Identifier of the referenced edge. Set when the reference is an edge.
from -> (string) [required]
The ID of the node where the edge starts.
Constraints:
- min:
0- max:
2048- pattern:
[\w\-\.#:@/%~]+to -> (string) [required]
The ID of the node where the edge ends.
Constraints:
- min:
0- max:
2048- pattern:
[\w\-\.#:@/%~]+documentId -> (string)
Identifier of the referenced document. Set when the reference is a document.
Constraints:
- min:
1
authorizationRequired -> (structure)
Present when you must authorize access to a third-party resource. If
retrievedContextis empty, no result was retrieved. Otherwise, the result leaves out one or more resources that you have not authorized. ShowauthorizationUrlto the user and retry after they consent.authorizationUrl -> (string) [required]
The URL the end user opens to consent. Single-use and bound to the caller’s identity.
Constraints:
- min:
1- max:
4096message -> (string)
A short, user-facing explanation of what is being authorized.
Constraints:
- min:
1- max:
1024