microsoft / microsoft/simplechat
[Generated documents] Add durable long-form Word document generation
- Dominant language
- Python
- Stars
- 152
- Forks
- 116
- Avg merge
- 7h 7m
- Merged PRs (30d)
- 122
Description
## 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 #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
- Editing an existing Office file, tracked by #969 and #999.
- Template selection or named-field population, tracked by #968 and #1045.
- Reusing the tabular CSV/JSON batch executor as the DOCX renderer.
## Related Work
- #1071 establishes the universal CSV output capability and should drive extraction of format-neutral durable artifact/job primitives.
- #482 delivered the original basic Word/PowerPoint/Excel/CSV output capability; this issue extends it to large, durable DOCX generation.
Contributor guide
Assessment
This issue has not been assessed yet.