Skip to main content

Function

Tool identifier document_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 (the document_parse tool itself needs no extra credentials; reading local files requires none)

Usage

examples/tools/document_parse/agent.py
Direct calls:

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: true in metadata. 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_chars is cut off and truncated is true.
  • PDF extraction reads embedded text only and does not run OCR on scans. A scanned PDF may come back with empty text and needs_ocr set to true in metadata; convert its pages to images and use ocr instead.
  • 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.
Last modified on November 20, 2026