Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/vectorize-io/hindsight/llms.txt

Use this file to discover all available pages before exploring further.

Operations are background tasks that Hindsight executes asynchronously. They are created when you retain content with async: true, upload files, or create mental models. Each operation has a lifecycle from pending through processing to a terminal state. You can poll operation status, cancel pending operations, and retry failed ones. By default, all background operations execute in-process within the API service.

Operation types

OperationTriggerDescription
batch_retainretain with async: trueProcesses content batches in the background
file_retainFile uploadConverts and ingests uploaded files
consolidateAfter retainConsolidates new facts into observations
mental_modelcreate_mental_model or refresh_mental_modelGenerates or refreshes a mental model

Operation status values

StatusDescription
pendingOperation is queued and waiting to be picked up
processingOperation is actively being processed by a worker
completedOperation finished successfully
failedOperation failed — check error_message for details
cancelledOperation was cancelled before processing began

List operations

GET /v1/{tenant}/banks/{bank_id}/operations
Returns all operations for the specified bank, ordered by creation time (most recent first).

Query parameters

status
string
Filter by operation status: pending, processing, completed, failed, cancelled.
limit
integer
default:"100"
Maximum number of operations to return.
offset
integer
default:"0"
Pagination offset.

Response fields

bank_id
string
required
The memory bank these operations belong to.
operations
object[]
required
List of operations.

Example

curl "https://your-hindsight-host/v1/default/banks/my-bank/operations" \
  -H "Authorization: Bearer $HINDSIGHT_API_KEY"

Get an operation

GET /v1/{tenant}/banks/{bank_id}/operations/{operation_id}
Returns the current status and details for a single operation.

Example

curl "https://your-hindsight-host/v1/default/banks/my-bank/operations/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer $HINDSIGHT_API_KEY"

Cancel an operation

DELETE /v1/{tenant}/banks/{bank_id}/operations/{operation_id}
Cancels a pending operation before it starts processing. Has no effect on operations that are already processing, completed, or failed.

Example

curl -X DELETE "https://your-hindsight-host/v1/default/banks/my-bank/operations/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer $HINDSIGHT_API_KEY"

Retry a failed operation

POST /v1/{tenant}/banks/{bank_id}/operations/{operation_id}/retry
Re-queues a failed or cancelled operation for execution. The operation status resets to pending and the worker picks it up again. Returns 409 if the operation is not in a retriable state.

Response fields

success
boolean
required
Whether the retry was successfully queued.
message
string
required
Human-readable confirmation message.
operation_id
string
required
The operation ID that was re-queued.

Example

curl -X POST "https://your-hindsight-host/v1/default/banks/my-bank/operations/550e8400-e29b-41d4-a716-446655440000/retry" \
  -H "Authorization: Bearer $HINDSIGHT_API_KEY"

Polling pattern

The recommended pattern for async retain is to submit the request, capture the operation ID, and poll until the operation reaches a terminal state.
import time
from hindsight_client import Hindsight

client = Hindsight(base_url="https://your-hindsight-host", api_key="...")

# Submit async retain
response = client.retain_batch(
    bank_id="my-bank",
    items=[{"content": "Large amount of content to process..."}],
    retain_async=True,
)
operation_id = response.operation_id

# Poll for completion
while True:
    op = await client.operations.get_operation_status("my-bank", operation_id)
    if op.status in ("completed", "failed", "cancelled"):
        break
    time.sleep(2)

if op.status == "completed":
    print("Processing complete")
elif op.status == "failed":
    print(f"Processing failed: {op.error_message}")

Error codes

StatusCodeDescription
400invalid_requestMalformed request.
401unauthorizedMissing or invalid API key.
404operation_not_foundThe specified operation does not exist.
409invalid_stateOperation is not in a retriable state (retry endpoint).
500internal_errorServer error.

Build docs developers (and LLMs) love