Skip to main content
The runtime package exposes four related capability contracts for knowledgebase access. Use the narrowest contract that matches the operation.

List and search knowledgebases

KnowledgebaseApi provides: Search supports vector, graph, and hybrid retrieval. Graph settings include neighborHops, entityTopK, communityTopK, and graphWeight.
Inspect result.diagnostics when filters or retrieval branches do not produce the expected result. Diagnostics report the effective filter, status, hit counts, latency, fallbacks, and stable error codes.

Idempotent plugin-written chunks

writeChunk() requires a stable writeKey. A retry can return status: 'skipped' instead of duplicating content. Use document.key when the plugin needs an independently managed document that can be placed in a folder.
Delete only keys owned by the plugin. deleteDocumentIfEmpty removes the managed document only after its chunks have been removed and the document is empty.

Provision managed knowledgebases

KnowledgebaseProvisioningApi has two idempotent operations: Each KnowledgebaseProvisioningSpec has a stable key, display metadata, permission (private, organization, or public), optional parsing defaults, a typed metadata schema, and an incremental-sync flag.
Keep namespace and each key stable across retries and upgrades. When inheritEmbeddingModel is enabled, the host reuses an accessible configured embedding model; provisioning fails explicitly if no suitable model is configured.

Manage persistent documents

KnowledgebaseDocumentsApi separates file upload from document creation and processing:
For archive import, set appropriate maxEntries, maxEntrySizeBytes, maxDepth, and supportedExtensions. Always surface skipped, warnings, and unsupported to an operator instead of treating a partial import as a complete success. Use expectedVersion when moving a document that may be edited concurrently.

Consume visual assets safely

KnowledgeDocumentVisualAssetsApi is a governed four-step lifecycle:
  1. issueCandidates() returns execution-scoped logical paths selected from text anchors and business scope.
  2. prepareImages() validates those paths and prepares portable inputs for immutable Artifact versions.
  3. consumeImageBatch() consumes a prepared batch and returns validated image payloads.
  4. discardImageBatch() releases a batch that will not be consumed.
The filePath returned for a visual candidate is not a host path and can only be resolved through this capability.
artifactInputs is server-only materialization data. Never copy it, batchRef, base64 image data, or logical paths into ToolMessage content or persisted chat metadata. Persist an Artifact or another governed reference when an image must outlive the current execution.