Skip to content

[Generated documents] Add durable long-form Word document generation #1072

Description

@paullizer

Summary

Add durable long-form Word document generation so a user, agent, or workflow can request a new DOCX from conversation, selected-source, or source-free evidence and receive an authorized downloadable artifact without relying on the synchronous single-message export route.

This is generation of a new document, not modification of an existing Office file or template population.

User Value

The current Word export is useful for a short message, but users also need complete deliverables such as five-, 20-, or 50-page reports, proposals, briefs, plans, and analysis packages. Those jobs can exceed normal request timeouts, message-size assumptions, and in-memory rendering expectations.

Current Limitation

/api/message/export-word renders one message synchronously and returns an immediate browser download. It has no durable job record, checkpointing, cancellation, resume/retry semantics, progress reporting, or artifact publication lifecycle for large multi-section document generation.

Proposed Behavior

  • Build a new DOCX from a natural-language request through Chat, Search, selected agents, Analyze, Compare, workflows, or source-free prompts.
  • Use a hierarchical document plan: validated outline, section-level content work, deterministic DOCX rendering, and final package validation.
  • Publish the completed document through the existing authorized generated-chat-artifact/download/promotion flow.
  • Use a generic durable generated-artifact job contract for queued/running/completed/failed/canceled state, leases, checkpoints, idempotent publication, cancellation, retry, and reauthorization.
  • Coordinate with [CSV exports] Support universal CSV generation across all paths and file types #1071 so the durable job and artifact-publication primitives are format-neutral; do not extend the CSV/tabular executor directly.
  • Keep DOCX planning and rendering format-specific, using the existing Word-native formatting helpers as a starting point.
  • Preserve normal immediate export for small single-message exports where appropriate.

Acceptance Criteria

  • Users can request a new DOCX through the supported generation paths rather than needing to first export an existing assistant message.
  • A long-form request can produce at least 5, 20, and 50-page-equivalent document workloads within configured safety and size limits.
  • Generation uses a persisted outline/section plan and checkpointed section progress rather than one unbounded model response.
  • The job exposes queued, running, completed, failed, and canceled states; supports authorized cancellation, retry/resume where safe, and progress visible from the originating conversation.
  • Source access, source revision, and conversation authorization are revalidated at execution and before artifact publication.
  • DOCX output renders headings, paragraphs, lists, tables, code, citations, images/charts where supported, and a configurable document structure without silently dropping planned sections.
  • Rendering failures, unsupported content, source coverage gaps, and partial documents are explicit and never published as a misleading complete report.
  • Completion creates one idempotently published, authorized downloadable chat artifact with existing workspace promotion support.
  • Small existing per-message Word export remains compatible and does not require a background job.
  • Functional tests cover short/long generation, multi-section checkpoints, cancellation, retry, authorization loss, source version change, artifact download, duplicate-publication prevention, and representative DOCX round-trip validation.

Non-Goals

Related Work

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status
Pending Evaluation

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions