file
Any file, such as an email attachment or an upload, with its name, type and size. What a file holds decides what it can be used as: one whose content is a PDF, a picture or a recording is accepted wherever that is expected.
At a glance
- Stored as: a handle (
file-…), kept once by its content and referred to by that handle. - Read in parts: by a range of lines.
- Media: served as stored, through a signed link.
- Search: by passage, so full-text and similarity search rank a value by its best passage.
Writing
- Send any bytes, with the file's name and media type when you have them: upload it, or
give create its
file, its bytes, an http(s) URL or adata:URI. The name, the media type (as given, else guessed from the name) and the size are kept with it. - An upload, or a file given to create without a
dtype, is stored as the type its content is: a PDF as a pdf, a picture as an image, a recording as audio, a file declaredtext/markdownas markdown (on upload, also one named.md), and anything else as a file. The content decides; the declared media type counts only when the bytes are not recognised. Thedtypein the answer, and the handle's prefix, say which it became. A very large upload stays a file whatever it holds. - create with
dtypefilekeeps a file, whatever it holds.
Written as
A JSON object.
__dtype__: str
Reading
- get_content reads the file's text by lines:
rangecounts lines from 1, andquerysearches them. - The text is: a text format (plain text, CSV, JSON, XML, HTML, markdown, logs, YAML) as it is; a Word, Excel or PowerPoint document converted to markdown; a PDF's own text, with pages that have none read from their images. Any other file, and one too large to load, reads as a one-line note in place of text; fetch it by its link instead.
- get_media returns a link to the stored file, valid for a
limited time. It takes no
format.
Querying
The text of text files, office documents and PDFs is indexed in passages; an archive (zip or tar) is indexed by its list of entries, so a search finds a file in it by name. Files above a size limit are not indexed. See the HQL reference.
SupportTicket | attachments.file ~~ "refund policy" | select id, match.text | limit 10
Message | ~* "quarterly report" | match.dtype = "file" | select id, match.field, match.text | limit 20
content.dtype asks whether a message carries a generic file, without searching. On a
list such as a message's content, size.bytes adds up every PDF, picture, recording and
file in it:
Message | content.dtype = "file" AND content.size.bytes > 10000000 | select id, content.size.bytes
In agent tools
- A tool argument that takes a pdf, image, audio or markdown value takes a file's handle when the file's content is that type, and refuses it, naming what it holds, when not.
- In a conversation the agent reads the file's text after its marker: whole when the file came with a message, and as much as fits, with how to read on, when a tool returned it.
- Over MCP and the command line, a file whose content is a PDF, a picture or a recording is shown as one.
Metadata
Derived values kept with a stored value:
text_excerpt: For a text file, its first 2 KB as text. Made the first time a preview needs it; absent for other files.line_count: For a text file, its number of lines, or -1 when the file is over 2 MB. Counted the first time it is read; absent for other files.content_listing: For a zip, tar or gzip archive, its first 500 entries, each withpath,sizeandis_dir. Listed the first time it is read; absent for other files.filename: The name the file was uploaded or attached with, when it had one. Kept when the file is stored.content_type: The file's media type, such astext/csv: as given with the file, else guessed from its name. Kept when the file is stored.size: The file's size in bytes. Kept when the file is stored.
Operations
Through the dtypes resource: