Skip to content

Lazy-load document conversion dependencies#19

Open
fortybyte wants to merge 1 commit intoVRSEN:mainfrom
fortybyte:codex/lazy-doc-conversion-imports
Open

Lazy-load document conversion dependencies#19
fortybyte wants to merge 1 commit intoVRSEN:mainfrom
fortybyte:codex/lazy-doc-conversion-imports

Conversation

@fortybyte
Copy link
Copy Markdown

Summary

  • Lazy-load document conversion dependencies so the Docs Agent can start even when PDF-only native dependencies are unavailable.
  • Keep WeasyPrint imports on the PDF export path and return a clear tool error when native PDF dependencies are missing.
  • Harden Docs tool path handling by validating project, document, and DOCX filenames before composing paths.
  • Skip render-only local image embedding for Markdown and TXT exports.

Root Cause

ConvertDocument imported WeasyPrint and other conversion stacks at module load. On systems missing WeasyPrint native libraries such as Pango, Agency Swarm skipped the conversion tool during startup. The same document tools also treated user-provided names as filesystem path components without rejecting path traversal patterns.

Impact

The Docs Agent keeps non-PDF conversion capability even when PDF native dependencies are not installed, PDF failures are actionable, and document tools stay inside the managed mnt/<project>/documents tree. Markdown and TXT exports avoid unnecessary render-time image processing.

Validation

  • python3 -m pytest tests/test_convert_document_pdf_dependency.py -q -> 7 passed
  • python3 -m pytest -q -> 7 passed
  • python3 -m py_compile docs_agent/tools/ConvertDocument.py docs_agent/tools/CreateDocument.py docs_agent/tools/ModifyDocument.py docs_agent/tools/ViewDocument.py docs_agent/tools/RestoreDocument.py docs_agent/tools/utils/doc_file_utils.py tests/test_convert_document_pdf_dependency.py
  • create_agency() startup smoke verified Docs Agent still registers ConvertDocument
  • Direct Markdown/TXT conversion smoke verified output files and content
  • git diff --check

@fortybyte fortybyte marked this pull request as ready for review May 8, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant