Knowledge.add() tells you which files failed so an outage in your embedding backend never looks like a successful import.
Quick Start
1
Simple usage
Point an agent at a folder and ask a question — indexing happens for you.
2
Check indexing succeeded
Call
add() directly and inspect result["errors"] to see which files failed.How It Works
Knowledge.add() walks the directory, embeds each file, and returns the successes and failures together.
A failed file is recorded instead of dropped, so a directory whose every file fails to embed no longer returns an empty-but-successful result.
Return shape
add() always returns these three keys — errors is present even on success (as an empty list).
add([...]) aggregates errors from every input path, so one bad directory never hides errors from another.
Failure modes
All files failed
All files failed
Every entry lands in
errors and results is empty. The log line names the first cause. Common causes: a wrong embedding model name, a revoked API key, or an exhausted quota.Partial failure
Partial failure
results holds the chunks that succeeded and errors names only the ones that failed. The import is not rolled back.Single-file add() where every chunk failed
Single-file add() where every chunk failed
The single-file path raises instead of returning silently:Wrap the call in
try / except RuntimeError if the caller wants to keep going.List input
List input
add([path1, path2, ...]) aggregates errors from every input path into one errors list.User interaction flow
Bulk-import a docs folder before deployment, then gate the deploy on the result.Common Patterns
Fail fast in CI:Best Practices
Always inspect result['errors'] after a bulk import
Always inspect result['errors'] after a bulk import
A non-empty
errors list is the only reliable signal that a file was skipped. Check it every time you index a folder.Treat a non-empty errors list as an outage signal
Treat a non-empty errors list as an outage signal
Failures usually mean the embedding backend is down — a wrong model name, a revoked key, or an exhausted quota. Alert on it rather than logging it as a warning.
Catch RuntimeError for single-file calls
Catch RuntimeError for single-file calls
The
errors list is populated on the directory and list paths. A single-file add() where every chunk fails raises RuntimeError, so wrap it in try / except if you need to continue.Trust errors whether the backend raised or returned empty
Trust errors whether the backend raised or returned empty
errors is populated whether the store raised an exception or returned an empty result — embedding backends do both, and both are captured.Related
Knowledge
Core knowledge concepts and how agents use a knowledge base.
Knowledge Storage
Where knowledge persists and how to change the location.
Knowledge Backends
Choose and configure the vector store behind your knowledge base.
Incremental Indexing
Re-index only the files that changed.

