SearchAgentContext
Searches an agent context for entities matching a query. Returns ranked entities with relevance scores and metadata. To see the edges around a result node, pass its node ID to TraverseAgentContext.
Request Parameters
- agentContextId
-
The agent context to search, by ID or full Amazon Resource Name (ARN).
Type: String
Length Constraints: Minimum length of 1. Maximum length of 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]+)*Required: Yes
- filter
-
Optional filter on node attributes: a single comparison, or
andAllof comparisons that must all match.Type: SearchFilter object
Note: This object is a Union. Only one member of this object can be specified or returned.
Required: No
- maxResults
-
Maximum number of results to return per page.
Type: Integer
Valid Range: Minimum value of 1. Maximum value of 50.
Required: No
- nextToken
-
Opaque continuation token from a prior response. Omit on the first page.
Type: String
Required: No
- query
-
The natural-language query or keywords to search for in the agent context. AWS Context interprets it based on
searchType: as literal text forKEYWORD, as a semantic concept forSEMANTIC, or as both forAUTO.Type: String
Length Constraints: Minimum length of 1. Maximum length of 35000.
Required: Yes
- searchType
-
The search strategy to use. Valid values:
-
KEYWORD- Full-text keyword matching (BM25). -
SEMANTIC- Vector similarity of embeddings. -
AUTO- Keyword matches first, then semantic matches for the remaining results.
Type: String
Valid Values:
KEYWORD | SEMANTIC | AUTORequired: Yes
-
Response Elements
The following elements are returned by the service.
- authorizationRequired
-
Present when the end user must authorize access to a third-party resource before the search 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.Type: AuthorizationRequired object
- items
-
The matching entities, ranked by relevance.
Type: Array of SearchAgentContextResultEntity objects
Array Members: Minimum number of 0 items. Maximum number of 50 items.
- nextToken
-
Pagination cursor for the next page. Absent when there are no more results.
Type: String
Errors
For information about the errors that are common to all actions, see Common Error Types.
- AccessDeniedException
-
You don't have sufficient access to perform this operation. Verify that you have permission to perform the operation on the resource.
- message
-
A message that describes the error.
HTTP Status Code: 403
- ConflictException
-
The request conflicts with the current state of the resource. Check the resource's current state before you retry the request.
- message
-
A message that describes the error.
- resourceId
-
The ID of the resource that caused the conflict. When several resources caused it, a comma-separated list of their IDs.
- resourceType
-
The type of the resource that caused the conflict.
Valid values:
-
agent-context- An agent context. -
connection- A connection. -
curation-policy- A curation policy. -
evaluation- Reserved for future use. -
ontology- An ontology. -
ontology-induction- An ontology induction. -
resource-policy- A resource-based policy.
-
HTTP Status Code: 409
- InternalServerException
-
The request failed because of an internal error. Retry the request.
- message
-
A message that describes the error.
HTTP Status Code: 500
- ResourceNotFoundException
-
The specified resource was not found. Check that the ID is correct and that the resource exists in your account and Region.
- message
-
A message that describes the error.
- resourceId
-
The ID of the resource that was not found.
- resourceType
-
The type of the resource that wasn't found.
Valid values:
-
agent-context- An agent context. -
connection- A connection. -
curation-policy- A curation policy. -
evaluation- Reserved for future use. -
ontology- An ontology. -
ontology-induction- An ontology induction. -
resource-policy- A resource-based policy.
-
HTTP Status Code: 404
- ThrottlingException
-
The request was denied because it exceeded a request rate quota. Wait, then retry the request.
- message
-
A message that describes the error.
- quotaCode
-
The code of the quota that throttled the request.
- retryAfterSeconds
-
The number of seconds to wait before you retry the request, if AWS Context provides one.
- serviceCode
-
The code of the service whose quota throttled the request.
HTTP Status Code: 429
- ValidationException
-
The input fails to satisfy the constraints of the operation. Correct the input before you retry the request.
- fieldList
-
The fields that failed validation, each with a message that describes why.
- message
-
A message that describes the error.
- reason
-
The reason that the input failed validation. Valid values:
-
unknownOperation- The operation isn't recognized. -
cannotParse- The request couldn't be parsed. -
fieldValidationFailed- One or more fields failed validation.fieldListdescribes them. -
other- Another reason.messagedescribes it.
-
HTTP Status Code: 400
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: