Context / Client / traverse_agent_context
traverse_agent_context¶
- Context.Client.traverse_agent_context(**kwargs)¶
Returns the neighbors of a seed node in an agent context, each with its properties, hop distance, and the edges that connect it to the seed. To get the seed node ID, call SearchAgentContext.
See also: AWS API Documentation
Request Syntax
response = client.traverse_agent_context( maxResults=123, nextToken='string', agentContextId='string', nodeId='string', traversalStrategy={ 'edgeTypes': [ 'string', ], 'direction': 'OUTGOING'|'INCOMING'|'BOTH', 'maxDepth': 123 } )
- Parameters:
maxResults (integer) – Maximum total neighbors to return per page.
nextToken (string) – Opaque continuation token from a prior response. Omit on the first page.
agentContextId (string) –
[REQUIRED]
The agent context to traverse, by ID or full Amazon Resource Name (ARN).
nodeId (string) –
[REQUIRED]
The ID of the seed node to start traversal from.
traversalStrategy (dict) –
[REQUIRED]
Traversal directives: which edge types to follow, direction, and max depth.
edgeTypes (list) –
Edge types to follow. When omitted, all edge types are traversed.
(string) –
The name of an ontology edge type: one or more segments of uppercase letters, digits, and underscores, each starting with a letter and separated by
::, for exampleWORKS_ONorAWS::BEDROCK_KNOWLEDGE_BASE::WORKS_ON. Up to 128 characters. A traversaledgeTypesfilter accepts the::form, so it can name any edge type that AWS Context ingests.
direction (string) – [REQUIRED]
Direction of edge traversal.
Valid values:
OUTGOING- Follow edges pointing away from the current node (source -> target).INCOMING- Follow edges pointing toward the current node (target -> source).BOTH- Follow edges in both directions.
maxDepth (integer) – [REQUIRED]
The maximum traversal depth from the seed node, from 1 to 3.
- Return type:
dict
- Returns:
Response Syntax
{ 'nextToken': 'string', 'items': [ { 'nodeId': 'string', 'properties': { 'string': { 'stringValue': 'string', 'intValue': 123, 'longValue': 123, 'boolValue': True|False, 'floatValue': ..., 'doubleValue': 123.0, 'stringListValue': [ 'string', ], 'intListValue': [ 123, ], 'longListValue': [ 123, ], 'floatListValue': [ ..., ], 'doubleListValue': [ 123.0, ], 'boolListValue': [ True|False, ] } }, 'depth': 123, 'pathEdges': [ { 'edgeId': { 'from': 'string', 'to': 'string' }, 'properties': { 'string': { 'stringValue': 'string', 'intValue': 123, 'longValue': 123, 'boolValue': True|False, 'floatValue': ..., 'doubleValue': 123.0, 'stringListValue': [ 'string', ], 'intListValue': [ 123, ], 'longListValue': [ 123, ], 'floatListValue': [ ..., ], 'doubleListValue': [ 123.0, ], 'boolListValue': [ True|False, ] } } }, ] }, ], 'authorizationRequired': { 'authorizationUrl': 'string', 'message': 'string' } }
Response Structure
(dict) –
The response of TraverseAgentContext.
nextToken (string) –
Pagination cursor for the next page. Absent when there are no more results.
items (list) –
The neighbors reached from the seed node.
(dict) –
A node that the traversal reached from the seed node, with its properties, its depth, and the edges on the path to it from the seed node.
nodeId (string) –
Unique identifier of the neighbor node.
properties (dict) –
Arbitrary key-value properties stored on this neighbor node.
(string) –
(dict) –
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 will be set:
stringValue,intValue,longValue,boolValue,floatValue,doubleValue,stringListValue,intListValue,longListValue,floatListValue,doubleListValue,boolListValue. If a client receives an unknown member it will setSDK_UNKNOWN_MEMBERas the top level key, which maps to the name or tag of the unknown member. The structure ofSDK_UNKNOWN_MEMBERis as follows:'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
stringValue (string) –
A string value, up to 2,048 characters.
intValue (integer) –
A 32-bit signed integer value.
longValue (integer) –
A 64-bit signed integer value.
boolValue (boolean) –
A Boolean value.
floatValue (float) –
A single-precision (32-bit) floating-point value.
doubleValue (float) –
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.
(string) –
intListValue (list) –
A list of up to 1,000 32-bit signed integer values.
(integer) –
longListValue (list) –
A list of up to 1,000 64-bit signed integer values.
(integer) –
floatListValue (list) –
A list of up to 1,000 single-precision (32-bit) floating-point values.
(float) –
doubleListValue (list) –
A list of up to 1,000 double-precision (64-bit) floating-point values.
(float) –
boolListValue (list) –
A list of up to 1,000 Boolean values.
(boolean) –
depth (integer) –
The depth at which the traversal found this neighbor (1 = directly connected to seed, 2 = two edges away, and so on).
pathEdges (list) –
The edges along the path from the seed node to this neighbor, preserving traversal order.
(dict) –
An edge on the path from the seed node to a neighbor node, with the edge’s properties.
edgeId (dict) –
Edge identity: the (from, to) node pair. Edges have no standalone ID. The edge type,
edgeType, is carried in properties.from (string) –
The ID of the node where the edge starts.
to (string) –
The ID of the node where the edge ends.
properties (dict) –
Arbitrary key-value properties stored on this edge.
(string) –
(dict) –
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 will be set:
stringValue,intValue,longValue,boolValue,floatValue,doubleValue,stringListValue,intListValue,longListValue,floatListValue,doubleListValue,boolListValue. If a client receives an unknown member it will setSDK_UNKNOWN_MEMBERas the top level key, which maps to the name or tag of the unknown member. The structure ofSDK_UNKNOWN_MEMBERis as follows:'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
stringValue (string) –
A string value, up to 2,048 characters.
intValue (integer) –
A 32-bit signed integer value.
longValue (integer) –
A 64-bit signed integer value.
boolValue (boolean) –
A Boolean value.
floatValue (float) –
A single-precision (32-bit) floating-point value.
doubleValue (float) –
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.
(string) –
intListValue (list) –
A list of up to 1,000 32-bit signed integer values.
(integer) –
longListValue (list) –
A list of up to 1,000 64-bit signed integer values.
(integer) –
floatListValue (list) –
A list of up to 1,000 single-precision (32-bit) floating-point values.
(float) –
doubleListValue (list) –
A list of up to 1,000 double-precision (64-bit) floating-point values.
(float) –
boolListValue (list) –
A list of up to 1,000 Boolean values.
(boolean) –
authorizationRequired (dict) –
Present when the end user must authorize access to a third-party resource before the traversal can run. In that case,
itemsis empty. ShowauthorizationUrlto the end user, and retry after the user consents. Through the agent context’s MCP server, you receive this as an MCP elicitation request that contains the URL.authorizationUrl (string) –
The URL the end user opens to consent. Single-use and bound to the caller’s identity.
message (string) –
A short, user-facing explanation of what is being authorized.
Exceptions