Hebbrix
Async Tasks

Background Jobs

Some tasks take time—like processing a 100-page PDF or analyzing a video. Background jobs let you start these tasks and check back later.

How It Works

Think of it like ordering food delivery: you place the order (start a job), get a tracking number (job ID), and check the status whenever you want. You don't have to wait around—just check back when convenient!

What Runs in the Background?

Document Processing

Upload large PDFs, Word docs, or presentations. Hebbrix extracts the text, breaks it into memories, and makes it searchable.

Media Analysis

Process videos and audio files. Hebbrix transcribes speech, identifies key moments, and creates searchable memories from your media.

Batch Operations

Update or delete thousands of memories at once. Instead of doing them one-by-one, batch jobs handle large-scale operations efficiently.

Memory Consolidation

Compress old memories to save space while keeping important information. This runs periodically in the background.

Job Statuses

Every job goes through these stages:

pending

Job is queued, waiting to start

running

Job is currently being processed

completed

Job finished successfully! Results are ready

failed

Something went wrong. Check the error message

Endpoints

Code Examples

Start a Document Processing Job

Python
from hebbrix import Hebbrix

client = Hebbrix()

# Start processing a large document
job = client.jobs.create(
    type="document_processing",
    file_url="https://example.com/large-document.pdf",
    collection_id="col_abc123"
)

print(f"Job started!")
print(f"Job ID: {job['id']}")
print(f"Status: {job['status']}")  # "pending" initially

# Save the job ID - you'll need it to check status later
job_id = job['id']

Check Job Status

Python
# Check job status
status = client.jobs.get(job_id)

print(f"Status: {status['status']}")
print(f"Progress: {status['progress']}%")

if status['status'] == 'completed':
    print("Job finished!")
    print(f"Result: {status['result']}")
elif status['status'] == 'failed':
    print("Job failed")
    print(f"Error: {status['error_message']}")

Wait for Completion (Polling)

Python
import time

def wait_for_job(job_id, max_wait=300):
    """Wait for job to complete (up to max_wait seconds)"""
    start_time = time.time()

    while True:
        status = client.jobs.get(job_id)

        if status['status'] == 'completed':
            print("Job completed successfully!")
            return status['result']

        elif status['status'] == 'failed':
            print(f"Job failed: {status['error_message']}")
            return None

        # Check if we've waited too long
        if time.time() - start_time > max_wait:
            print("Timeout waiting for job")
            return None

        # Wait 5 seconds before checking again
        print(f"Status: {status['status']} ({status['progress']}%)")
        time.sleep(5)

# Use it
result = wait_for_job(job_id)
if result:
    print(f"Processed {result['memories_created']} memories!")

Pro Tips

  • Save job IDs! You need them to check status later
  • Don't poll too frequently—check every 5-10 seconds is enough
  • Jobs older than 30 days are automatically deleted (but results are saved)
  • You can have multiple jobs running at once

Next Steps

Assistant

Ask me anything about Hebbrix