The Core Insight
Don’t build agents that query your data. Build agents that run where your data lives. For documents, this means: agent code runs in the same process boundary as the data. No remote calls to fetch pages. No separate storage service. Data and computation are one unit.Traditional vs Colocated
Traditional Stack- Agent is external service
- Agent makes calls to storage service for document
- Agent makes calls to database for metadata
- Agent and data are separate systems
- Agent runs in same boundary as document
- Agent reads local state directly
- Agent has full context immediately available
- No intermediate services between agent and data
How It Works
When user uploads PDF:- Agent reads pages from local storage
- Agent constructs context from local state
- Agent calls LLM API with complete context
- PDF stays within DO boundary
Mixed Data Sources
Agents rarely analyze only PDFs. They combine:- Local (colocated): PDF content, tables, entities, chat history
- Remote (on-demand): Database queries, API calls, external tools
Why This Matters
A PDF isn’t just bytes. It’s:- Extracted text and tables
- Entity positions and confidence scores
- User’s previous questions and chat history
- Processing metadata (OCR status, vendor used, etc.)
- Storage service stores bytes
- Database stores metadata
- Agent queries both separately
The Trade-offs
What you gain:- Agent owns the full PDF context
- Agent runs in same boundary as data
- Agent is the primary interface to document
- Simpler app code (no service orchestration)
- Each document gets its own agent instance
- Agent state is isolated per PDF