Back to Articles
AI
April 6, 2026

AI Agents for Your Filesystem: Semantic Search & Auto-Organization

GR

George Rios

Edge Architect & Cloudflare Specialist

Your filesystem is dumb. It knows filenames, dates, sizes, and folder paths. It has no idea what's inside your files, what they're about, or how they relate to each other. You're the index. Your memory is the search engine. And when your memory fails — when you can't remember whether that contract is in Documents/Legal or Downloads/2025 or buried in an email attachment you saved somewhere — you're stuck grepping through directories or scrolling through Finder.

We're building something different into DoubleSpace. An AI layer that understands your files the way you do — by meaning, not by metadata. Using Workers AI for inference and Vectorize for vector storage, we're turning a cloud sync platform into an intelligent file management system.

The vision: files that understand themselves

The idea is straightforward, even if the implementation isn't. Every file uploaded to DoubleSpace goes through an AI pipeline that extracts its meaning and makes it searchable. Not just the text content — the concepts, the topics, the intent.

This enables three things that traditional filesystems can't do:

  • Search by meaning. Find files based on what they're about, not what they're named.
  • Automatic organization. Tag and categorize files without manual effort.
  • Natural language queries. Ask questions about your file data and get answers.

Search by meaning, not filename

Traditional file search is keyword-based. You type "invoice" and it finds files with "invoice" in the name or content. But what about the file named 2026-Q1-AP.pdf that is absolutely an invoice but doesn't contain the word "invoice" anywhere? What about the spreadsheet labeled vendor-payments.xlsx that's functionally an invoice ledger?

Semantic search solves this. When a file is uploaded, DoubleSpace extracts its text content (using format-specific parsers for PDF, DOCX, XLSX, etc.) and generates a vector embedding using Workers AI. This embedding is a high-dimensional numerical representation of the file's meaning — a point in semantic space where similar documents cluster together.

// Generate embedding for a document
const embedding = await env.AI.run(
  '@cf/baai/bge-base-en-v1.5',
  { text: [extractedContent] }
);

// Store in Vectorize
await env.VECTORIZE.insert([{
  id: fileId,
  values: embedding.data[0],
  metadata: { workspaceId, filename, mimeType }
}]);

These embeddings are stored in Vectorize, Cloudflare's vector database. When you search for "invoices from last quarter," the query itself is embedded into the same vector space, and Vectorize returns the nearest neighbors — files whose meaning is closest to your query, regardless of their filenames or exact text content.

The results are surprisingly good. A search for "project timeline" returns Gantt charts, project plans, sprint schedules, and milestone documents — even if none of them contain the exact phrase "project timeline." The embedding model understands that these concepts are semantically related.

Auto-tagging with AI classification

Filing is busywork. Every file you manually tag, categorize, or sort into a folder is time you're spending being a human database index. DoubleSpace's AI layer automates this.

When a file is processed by the background Queue consumer, it runs through a classification pipeline in addition to embedding generation. Workers AI evaluates the content and assigns tags from a configurable taxonomy: document type (contract, invoice, report, presentation), topic (finance, engineering, legal, marketing), sensitivity level (public, internal, confidential), and project association.

The classification uses a combination of approaches. For structured document types (invoices, contracts), we use pattern matching on the extracted text — invoices have line items and totals, contracts have signature blocks and effective dates. For broader topic classification, we use Workers AI's text classification capabilities, prompting a model with the document summary and the available tags.

Users can correct any auto-tag, and those corrections feed back into the system. Over time, the classification accuracy improves for each workspace as it learns from corrections. This feedback loop is stored in D1 alongside the file metadata — each correction is a training signal that adjusts confidence thresholds for future classifications.

Natural language questions about your data

This is the feature that changes how people think about their files. Instead of searching and then reading documents to find an answer, you ask the question directly.

"What was our total spend with Acme Corp last year?" DoubleSpace finds the relevant invoices and purchase orders via semantic search, extracts the financial data, and synthesizes an answer. "Which contracts expire in the next 90 days?" It finds contracts, parses the expiration dates, and returns a sorted list.

The architecture behind this is a retrieval-augmented generation (RAG) pipeline. The user's question is embedded and used to retrieve relevant documents from Vectorize. The retrieved document chunks are then passed as context to a language model running on Workers AI, which generates a natural language answer grounded in the actual file data.

// RAG pipeline
const queryEmbedding = await env.AI.run(
  '@cf/baai/bge-base-en-v1.5',
  { text: [userQuestion] }
);

const relevant = await env.VECTORIZE.query(
  queryEmbedding.data[0],
  { topK: 5, filter: { workspaceId } }
);

const context = await fetchDocumentChunks(relevant.matches);

const answer = await env.AI.run(
  '@cf/meta/llama-3.1-8b-instruct',
  {
    messages: [
      { role: 'system', content: 'Answer based only on the provided context.' },
      { role: 'user', content: `Context:\n${context}\n\nQuestion: ${userQuestion}` }
    ]
  }
);

The "answer based only on the provided context" instruction is critical. It prevents the model from hallucinating information that doesn't exist in the user's files. If the answer isn't in the retrieved documents, the model says so rather than making something up.

Architecture: everything stays on Cloudflare

The entire AI pipeline runs within Cloudflare's infrastructure, which matters for two reasons: latency and data sovereignty.

Workers AI runs inference at the edge, close to the user. Embedding generation for a typical document takes 50-200ms. Classification adds another 100-300ms. These operations happen in the background via Queues, so the user never waits for them — they upload a file and it's available immediately, with AI features appearing within seconds as the queue processes.

Vectorize stores all embeddings within Cloudflare's network. Vector search queries return results in under 50ms, even across tens of thousands of documents. Combined with the D1 metadata lookup to resolve file IDs to names and paths, a full semantic search completes in under 200ms end-to-end.

D1 stores all metadata: file records, tags, classification confidence scores, user corrections, and the mapping between file IDs and their vector representations. This keeps the relational queries fast (list all files tagged "contract" sorted by date) while delegating the semantic queries to Vectorize.

The key architectural decision was making the AI pipeline entirely asynchronous. File uploads hit the Worker, which stores the file in R2, writes metadata to D1, and enqueues an AI processing job. The Queue consumer handles embedding generation, classification, and vector insertion. If Workers AI is slow or temporarily unavailable, the file is still accessible — it just won't have AI features until the queue catches up.

Integration with DoubleSpace's sync infrastructure

The AI layer isn't a separate product. It integrates directly into DoubleSpace's existing sync architecture. When the CLI syncs a file from your local machine, the same AI pipeline processes it. When you mount your workspace as a FUSE drive and save a document, the file watcher detects the change, syncs to R2, and triggers AI processing.

Search results appear in both the web UI and the CLI. You can run dblspc search "quarterly revenue report" from the terminal and get semantically relevant results without opening a browser. The CLI displays results with relevance scores, file paths, and the matched content snippets.

Real-time updates flow through the existing Durable Object SyncRoom. When AI processing completes for a file (tags assigned, embedding indexed), the SyncRoom broadcasts the update to all connected clients. Your web UI shows newly assigned tags appearing on files in real-time, without a page refresh.

The practical UX

Technology is only interesting if it changes how people work. Here's what AI-powered file management actually looks like day-to-day.

You upload a batch of documents from a client meeting. Within seconds, they're automatically tagged: "contract," "proposal," "meeting-notes," "financial." You didn't create folders. You didn't rename anything. The files are organized by meaning.

A week later, you need to find something from that meeting. You don't remember the filename. You type "the proposal we discussed with the client about the Q2 expansion" into the search bar. The proposal comes up first, followed by the meeting notes that reference it. You find what you need in five seconds instead of five minutes of folder-browsing.

Your manager asks "what's our total outstanding across all active contracts?" You type that question into DoubleSpace. It finds the relevant contracts, extracts the financial terms, and gives you a summary. No spreadsheet required.

That's the promise of AI-native file management. Your files become a knowledge base, not a filing cabinet. The AI does the indexing, categorization, and retrieval work that humans have been doing manually since the invention of the folder metaphor in 1981.

And it all runs at the edge, on Cloudflare, with zero servers to manage.

Related articles