Skip to content

feat: [CMPS-1256] add bulk delete_documents to the clients - #239

Merged
corafid merged 1 commit into
mainfrom
corafid/feat/delete-documents
Oct 6, 2026
Merged

corafid merged 1 commit into
mainfrom
corafid/feat/delete-documents

Conversation

@corafid

@corafid corafid commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

SDK counterpart for the API change for supporting bulk deletion of documents.


[🤖 Rafid's Bot · opencode · cohere-llm-gateway/claude-opus-5-5] Everything below this line is AI generated.

Adds delete_documents(*, index_name, document_ids, ...) to CompassClient and CompassAsyncClient, for the new Compass endpoint POST /v1/indexes/{index_name}/documents/_delete (cohere-ai/compass#3542). Retention jobs can then delete up to 1,000 documents in a single request instead of sending one request per document.

  • It returns DeleteDocumentsResult, which gives each unique ID a status of deleted or not_found.
  • MAX_BULK_DELETE_DOCUMENT_IDS = 1000 is exported from cohere_compass.constants. An empty list, or more than 1,000 IDs, raises ValueError before any request is sent. Callers do their own batching.
  • Errors and retries work the same way as every other method. A 5xx means the whole batch failed and is safe to retry, so automatic retries are correct here.
  • The version goes up to 2.22.0, as the version-bump check requires.
  • examples/fern_documentation/python/core/delete_docs.py is the target of the endpoint's OpenAPI x-codeSamples link.

Merge order: the API PR should land first. Before then, calling this method returns 404.

Tested with mocked-HTTP tests for both clients, plus a manual round trip of the sync and async clients against a local API built from the compass branch.

CMPS-1256

Retention policies and other clean-up jobs need to delete many documents
at once. Deleting them one by one costs a request per document; the new
POST /v1/indexes/{index_name}/documents/_delete endpoint takes up to 1000
IDs in a single request and reports per-document status.

The SDK rejects empty or oversized batches client-side and leaves
batching to callers.
@corafid
corafid marked this pull request as ready for review October 6, 2026 18:52
@corafid
corafid requested a review from a team as a code owner October 6, 2026 18:52
@corafid
corafid requested a review from dbaxter-cohere October 6, 2026 18:52
@corafid
corafid merged commit f03ed99 into main Oct 6, 2026
11 checks passed
@corafid
corafid deleted the corafid/feat/delete-documents branch October 6, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants