Function
Tool identifierdocument_parse.
document_parse parses a local or public document into bounded plain text for the agent to read and summarize. It supports PDF, Word, Excel, CSV, TXT, Markdown, JSON, and HTML; the format can be supplied explicitly or detected from the extension, response headers, and file content.
Import path: from veadk.tools.builtin_tools.document_parse import document_parse
Prerequisites
Environment variables:MODEL_AGENT_API_KEY: API key for the agent’s reasoning model (thedocument_parsetool itself needs no extra credentials; reading local files requires none)
Usage
examples/tools/document_parse/agent.py
Parameters
When
format is omitted, detection falls through the file extension, the URL response Content-Type, magic-byte signatures, an HTML sniff, and finally UTF-8 plain text.
Success returns {"format", "text", "truncated", "metadata"}. metadata always contains source_kind (file or url), size_bytes, download_truncated, and the detected format; local files add path, URLs add url, requested_url, and content_type, and parsers add pages/needs_ocr (PDF), paragraphs/tables (Word), sheets/total_rows (Excel), or delimiter/rows (CSV). On failure it returns {"error": ...}.
Notes
Limits and boundaries:
- A local file larger than 20,000,000 bytes returns an error; a remote body is truncated at 20,000,000 bytes with
download_truncated: trueinmetadata. Downloads time out after 30 seconds and follow at most 3 redirects. - Excel parses at most the first 50 sheets and the first 1,000 rows per sheet; CSV parses at most the first 5,000 rows; text beyond
max_charsis cut off andtruncatedistrue. - PDF extraction reads embedded text only and does not run OCR on scans. A scanned PDF may come back with empty text and
needs_ocrset totrueinmetadata; convert its pages to images and useocrinstead. - URL downloads use the same SSRF protection as
http_request, blocking private and loopback addresses; downloads do not support custom headers, so links behind login cannot be parsed.