Back to gallery

Document-Reading Agents

Give your AI agents one tool to read any document — 100+ formats, structured output, every framework.

ExtractEnrich
document → structured outputextract()
parser.py
def extract(doc):
return parse(doc)
class Reader:
# 306 formats
{
"functions": 12,
"classes": 3
}

What it looks like in practice

Picture an agent asked to answer a question from a customer's uploaded contract — a 40-page scanned PDF with a few tables. Before it can reason about anything, the agent has to open that file, read it in the right order, and get the tables out intact. That single “read the document” step is where most agent workflows quietly break.

Why documents break agents

Agents think in text and tool calls. They can't natively open a PDF, a DOCX, or a scan — so you bolt on a loader for each format. Every format brings its own failure mode: scans need OCR, spreadsheets need structure, multi-column pages need reading-order detection, and headers and footers leak into the text. The agent's tool surface turns into a pile of format-specific loaders that work on the happy path and fall over on the next unusual file.

Worse, when extraction is subtly wrong — a scrambled reading order, a dropped table, a header glued onto a paragraph — the agent has no way to know. It reasons over the garbled text and hands back a confident, wrong answer. Bad input doesn't raise an error; it produces a plausible hallucination.

One tool, any document

Xberg gives the agent a single read-any-document tool. It detects the format, runs OCR when the page is a scan, preserves tables and reading order, and returns structured, machine-readable content the model can actually reason over — the same call whether the file is a clean PDF, a photographed form, or a spreadsheet.

  • Reads 100+ formats — native and scanned — behind one interface.
  • Preserves reading order and table structure, so the model sees the document the way a person would.
  • Returns structured output: clean text, tables, and metadata, not a wall of scrambled characters.
  • Ships native tools for LangChain, LlamaIndex, and CrewAI — drop it into the agent you already have.
  • Same API in 12 languages, so your stack stays consistent.

In code

Register Xberg as a tool and the agent calls it on its own whenever it needs to read a file:

crew.py
from crewai import Agent
from crewai_tools import XbergTool
analyst = Agent(
role="Contract Analyst",
goal="Answer questions grounded in uploaded documents",
tools=[XbergTool()],
)
# The agent decides when to read:
# "Open contract.pdf and list the termination clauses."

What the agent receives

Instead of raw bytes, the model gets structured content it can ground its answer in:

tool_output.json
{
"content": "MASTER SERVICES AGREEMENT\n\n1. Term and Termination…",
"tables": [{ "rows": 6, "columns": 3 }],
"metadata": { "format": "pdf", "pages": 40, "ocr": true }
}

Why it matters for agents

  • One tool instead of five — a smaller, more reliable tool surface for the agent.
  • Clean input means fewer confident-but-wrong answers from garbled text.
  • Framework-agnostic: the same extraction behind LangChain, LlamaIndex, or CrewAI.
  • Self-hostable, so agents can read sensitive documents without anything leaving your environment.
Want to see the structured output your agent would receive? Run the open-source library on one of your own files and inspect the result in minutes.

Open-source primitives, composed into one backend. Curated cohort of design partners. Apply to work with us.

Cookies

We value your privacy

Xberg uses cookies to improve your experience, personalize content, and analyze traffic. You can manage your preferences at any time.