Skip to main content

Function

Tool identifier doc_generate. doc_generate creates Word, Excel, CSV, or Markdown documents. When called by an agent, the document is saved as a conversation artifact; when called directly from code, it is written to the system temporary directory and the path is returned. The tool is an async function (async def); once registered with Agent, the framework awaits it automatically. Import path: from veadk.tools.builtin_tools.doc_generate import doc_generate

Prerequisites

Environment variables:
  • MODEL_AGENT_API_KEY: API key for the agent’s reasoning model (the doc_generate tool itself needs no extra credentials and accesses no external services)
python-docx and openpyxl, required for Word and Excel, ship with the base VeADK dependencies, so no extras are needed.

Usage

examples/tools/doc_generate/agent.py
Direct calls require await:
For Excel, pass worksheets through sheets; for CSV, pass rows through rows:

Parameters

Format-specific caps:
  • Excel allows at most 20 sheets, 5,000 rows per sheet, and 100 columns.
  • CSV allows at most 10,000 rows and is written as UTF-8 without a byte-order mark.
  • Filenames are at most 120 characters and any directory portion is removed.
Success returns {"filename", "format", "size_bytes", "mime_type", "truncated", "artifact_saved", "path"}. For agent calls the artifact is saved and artifact_saved is true; for direct calls the file is written to a temporary directory and its path is returned in path. On failure it returns {"error": ...}.

Notes

  • To prevent spreadsheet formula injection, cells starting with =, +, -, or @ are written as text in Excel; in CSV such values get a leading apostrophe so spreadsheet applications open them as text.
  • truncated is true when sheets, rows, or columns exceeded the caps, so the generated file contains less than the input.
  • Temporary files created by direct calls are not cleaned up automatically; the application should delete the temporary directory after use.
Last modified on November 26, 2026