View a markdown version of this page

Remove an ontology from Agent Contexts - AWS Context

Remove an ontology from Agent Contexts

Before you delete an ontology, remove it from every Agent Context that uses it. What you do depends on the Agent Context’s status:

  • ACTIVE – Remove the ontology from the Agent Context’s connection mappings, or replace it with another published ontology.

  • FAILED – You can’t update a failed Agent Context. Delete the Agent Context to remove its use of the ontology.

  • CREATING or UPDATING – Wait until the Agent Context is ACTIVE or FAILED, and then follow the step for that status.

  • DELETING – No action is needed. An Agent Context that is being deleted doesn’t block the deletion.

You can find and remove the ontology on the AWS Context console or with the API. If removing or replacing the ontology fails, see You can’t remove or replace the ontology in an Agent Context.

Find and remove the ontology on the console

To find the Agent Contexts that use an ontology on the AWS Context console, follow these steps:

  1. In the navigation pane, choose Ontologies.

  2. Find the ontology in the list, and check the Used in agent contexts column. The ontology’s detail page shows the same value.

The Used in agent contexts column counts only connection mappings. It doesn’t count an Agent Context that you associated the ontology with for grounding.

To remove or replace the ontology in an Agent Context on the AWS Context console, follow these steps:

  1. In the navigation pane, choose Agent context, and then choose the Agent Context.

  2. Choose the Connections tab.

  3. Select the connection that uses the ontology. The Actions menu is available only after you select a connection.

  4. Do one of the following:

    • To change the ontologies, choose Actions, and then choose Edit. In the Edit connection mapping panel, under Extraction, find Ontology. In Choose ontologies, clear the ontology, and choose another ontology if you want to replace it. You can choose up to 10 ontologies. Then choose Save configuration.

    • To stop mapping the connection, choose Actions, and then choose Remove. In the Remove connection dialog, enter confirm, and then choose Remove. Removing the connection also deletes the entities and relationships that it added to the Agent Context.

These actions are available only while the Agent Context is ACTIVE. You can change the ontology only on an Amazon Bedrock Managed Knowledge Base connection. For an AWS Glue Data Catalog connection, the Edit connection mapping panel has only data filtering settings, and the console doesn’t show an ontology.

Find and remove the ontology with the API

To find the Agent Contexts that use an ontology with the API, call ListAgentContexts. Then call GetAgentContext for each Agent Context. In each response, check the ontologyId values in connectionMappings for the ontology’s ID or ARN.

The following example shows the inputs for ListAgentContexts and GetAgentContext. It isn’t a complete request.

ListAgentContexts nextToken: <next-token> GetAgentContext agentContextId: <agent-context-id>

Replace the following values:

  • <next-token> – the nextToken from the previous response.

  • <agent-context-id> – the ID of an Agent Context from ListAgentContexts.

To remove or replace the ontology in an Agent Context, call UpdateAgentContext with the complete list of connection mappings that you want to keep (connectionMappings). The list replaces the stored list.

Important

Include every mapping that you want the Agent Context to keep, not only the one that you’re changing.

To remove the ontology, leave out its mapping. To replace it, change the mapping’s ontologyId to a different published ontology.

The following example replaces the ontology in an Agent Context that has one connection mapping. It isn’t a complete request.

UpdateAgentContext agentContextId: <agent-context-id> connectionMappings: - connectionId: <connection-id> ontologyMappings: - ontologyId: <ontology-id>

Replace the following values:

  • <agent-context-id> – the ID or ARN of the Agent Context to update.

  • <connection-id> – the mapping’s connectionId from GetAgentContext.

  • <ontology-id> – the ID or ARN of the replacement ontology.

Keep the following in mind:

  • The replacement ontology must be published. Otherwise, the call fails with a ValidationException.

  • You can use a custom ontology only on an Amazon Bedrock Managed Knowledge Base connection. On other connection types, the mapping uses a built-in ontology.

  • A connection mapping can include up to 10 ontologies. When it includes more than one, AWS Context combines them. If they can’t be combined, the call fails with a ValidationException.

  • When you add an ontology to a connection mapping, AWS Context extracts the connection’s documents again and loads the ontology into the Agent Context. When you remove an ontology from a connection mapping, AWS Context doesn’t clean up anything. The ontology’s schema stays loaded in the Agent Context.

For the UpdateAgentContext request fields, see the next section, UpdateAgentContext request fields.

To confirm that the ontology is removed or replaced, call GetAgentContext. The change is complete when the ontology no longer appears in connectionMappings and the Agent Context’s status is ACTIVE.

If UpdateAgentContext fails, see You can’t remove or replace the ontology in an Agent Context.

UpdateAgentContext request fields

The following table describes the fields in the request that this guide uses. If you leave out an optional field, its stored value doesn’t change.

Field Description and rules

agentContextId

Required. The Agent Context to update, by its ID or ARN. The Agent Context must be ACTIVE. Otherwise, the call fails with a ConflictException.

connectionMappings

Optional. The connection mappings to keep, 0 to 20. The list replaces the stored list. Mappings that you leave out are removed. Each mapping that you keep is overwritten with exactly the values that you send. An empty list removes all connection mappings. If you leave out connectionMappings, the mappings don’t change.

entityResolutionConfig

Optional. Its status is ENABLED or DISABLED. It turns entity resolution and the grounding of AWS Glue Data Catalog tables on or off together. For more information, see Turn grounding off and on.

Each entry in connectionMappings has its own fields. The following table describes the fields in each entry.

Field Description and rules

connectionId

Required. The connection, by its ID or ARN. Every connection in the list, including ones that you keep, must exist, belong to your account, and be ACTIVE.

ontologyMappings

Required. 1 to 10 entries, each with the ontologyId of a published ontology. A custom ontology is accepted only on an Amazon Bedrock Managed Knowledge Base connection.

dataFilter, extractionDepth, and pathSegments

Optional. A mapping that you keep is overwritten with exactly the values that you send. So send these fields again for each mapping that uses them.