Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Error Handling

What breaks, why it breaks, and how to handle it across every SDK.

Common Errors

StatusMeaningTypical Cause
400 Bad RequestInvalid inputBad event_kind, payload over 256KB, too many link IDs (>100 total), invalid context_id format
401 UnauthorizedAuth failureMissing or invalid LOCUSGRAPH_AGENT_SECRET
404 Not FoundResource missingContext doesn't exist (when calling getContext)
429 Rate LimitedToo many requestsSlow down or batch your calls
The most common mistake: forgetting to set LOCUSGRAPH_AGENT_SECRET. Every SDK call will return 401 until it is configured.

Handling Errors by Language

TypeScript:
try {
  await client.storeEvent({ ... });
} catch (error) {
  if (error instanceof Error) {
    console.error('Store failed:', error.message);
  }
}
Python:
try:
    client.store_event({...})
except RuntimeError as e:
    print(f"Store failed: {e}")
Rust:
match client.store_event(request) {
    Ok(response) => println!("Stored: {}", response.event_id),
    Err(e) => eprintln!("Store failed: {}", e),
}

Validation Constraints

Stay within these limits to avoid 400 errors:

ConstraintLimit
Event kind max length128 characters
Context ID max length256 characters
Link IDs per field (reinforces, contradicts, etc.)50
Total link IDs across all fields100
Payload max size256KB
Batch events max100 per call
If you hit 429 rate limits, switch to batch event storage. One batch call with 50 events is better than 50 individual calls.

Next

Environment Variables
Response Format