Files

2.9 KiB

Documents and retrieval model

Documents in the extension system fall into two categories.

10.1 Thread-attached documents

Chat retrieval works against thread-attached files.

The retrieval settings struct is DocumentRetrievalSettings:

{
  "maxChunks": 8,
  "taggedFiles": ["opaque-document-id"]
}

Only files attached to the thread are accepted by validated_tagged_files() unless a specialized path explicitly provides a different mapping.

10.2 Document snapshots for retrieval/search

Invoke upsert_document_snapshot with threadId, the selected modelId, a display-only documentName, content, and optional maxChunkSize. Create the scoped extension thread before preparing the snapshot. The host validates its immutable launch workspace/group and extension ownership, then routes processing according to the selected model's execution location.

The reply includes opaque documentId and documentName references, threadId, modelId, processing state and display metadata. Attach that opaque reference to the same thread and use it in taggedFiles. Native local snapshots use the shared document processor and scoped native identity registry. Remote snapshots use private dashboard attachments and dashboard processing. Sources and indexes expire under the workspace retention policy.

get_document_snapshot validates an existing reference and returns its current thread/model scope and readiness. delete_document_snapshot accepts the opaque reference as documentName; the host removes only that extension's authorized snapshot, without deleting a shared group original. Cache entries must match both the conversation and selected model before reuse.

10.3 Important rule

Being present in vector storage does not automatically make a document part of every chat. Retrieval still depends on how the thread and request identify allowed files.

10.4 Dashboard conversation documents

Dashboard chat accepts opaque StreamChat.attachment_ids, resolved against server-owned conversation_document records for the authenticated owner, selected workspace/group and conversation. Canonical list/read/search executors receive only this captured scope and recheck current authorization during execution. A display name is used only to resolve an unambiguous already-authorized document. Uploading a private chat attachment does not grant an extension access to that attachment or create a browsable group file.

Use ProcessConversationAttachment with workspace_file_id, workspace/group/conversation and an expected sync revision to ingest an already-authorized group file without a desktop download. The resulting document_id belongs to this conversation; the source artifact remains a persistent workspace-file generation. Existing extension filesystem grants and launch scope continue to govern access to group sources.