Document-Wide AI Editing in Microsoft Word Add-In

harvey · Legal · 2025 · source Agentic: yes · promotional bias: med · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Legal document-wide editing inside Microsoft Word

Harvey needed to edit entire long legal documents from one instruction while preserving Word document structure, avoiding long-context coverage gaps, and keeping legal edits consistent across many pages.

Constraints:

Architecture

Harvey separates document engineering from model reasoning. It maps OOXML objects to a natural-language document representation, asks models to propose text-level edits, deterministically maps those edits back to OOXML mutations through the Word JavaScript object model, and uses an orchestrator-subagent architecture for full-document coverage. The orchestrator reads the whole document, decomposes work into bounded chunks, and gives subagents precise localized instructions plus global consistency constraints.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  word-document["Word document"] --> ooxml-to-text-mapper["OOXML-to-text mapper"]
  ooxml-to-text-mapper --> orchestrator-model["Orchestrator model"]
  orchestrator-model --> subagent-editors["Subagent editors"]
  subagent-editors --> deterministic-ooxml-applier["Deterministic OOXML applier"]
  ooxml-to-text-mapper --> deterministic-ooxml-applier["Deterministic OOXML applier"]
  deterministic-ooxml-applier --> word-javascript-object-model["Word JavaScript object model"]
  word-javascript-object-model --> word-document["Word document"]
  evaluation-framework["Evaluation framework"] --> orchestrator-model
  evaluation-framework --> subagent-editors
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Word document OOXML-backed legal document with text, formatting, styles, tables, and relationships. OOXML-to-text mapper
OOXML-to-text mapper Creates a reversible natural-language representation of document structure/content. Orchestrator model, Deterministic OOXML applier
Orchestrator model Reads the whole document, plans the work, assigns bounded chunk tasks, and sets global constraints. Subagent editors
Subagent editors Apply precise localized edit instructions over bounded document chunks. Deterministic OOXML applier
Deterministic OOXML applier Translates text-level edits back into Word object model changes while preserving structure. Word JavaScript object model
Word JavaScript object model Applies edits through supported Word APIs rather than raw XML generation. Word document
Evaluation framework Automated and expert-led metrics for coverage, request alignment, and implementation experiments. Orchestrator model, Subagent editors

Data flow

A user gives a document-wide edit instruction in the Word Add-In. Harvey converts the OOXML-backed Word document into a reversible natural-language representation, the orchestrator plans and chunks the work, subagents edit localized sections, global constraints maintain consistency, and deterministic translation applies the edits back into Word while preserving styles, numbering, tables, and content controls.

“We translate the OOXML to a natural language representation of the document, ask the model to propose edits over text, then deterministically translate those edits back into precise OOXML mutations that preserve styles and structure.”article, stated
“An orchestrator model reads the whole document, plans the work, and decomposes the request into targeted tasks that each operate on a bounded chunk.”article, stated

Why this architecture

Harvey separates OOXML manipulation from legal reasoning because raw OOXML generation is verbose, interdependent, and brittle. It then uses orchestration and subagents because one-shot long-context editing under-edits the middle and is slower/costlier without guaranteeing recall.

“Having a model read and write OOXML leads to an increased chance of poor-quality outcomes and is less efficient with regards to input token usage.”article, stated
“In practice, we see position bias: Models over-attend to the beginning or end of the context and under-edit the middle”article, stated

Models used: Orchestrator model (unspecified) · Subagent models (unspecified) · Multi-model Harvey stack · Microsoft Word JavaScript API

Scale

Alternatives considered (roads not taken)

Have models read and write OOXML directly

Rejected because: OOXML is verbose and interdependent, and constrained XML generation hurts reasoning quality and validity.

“Unconstrained generation often produces invalid or schema-nonconformant XML.”article, stated

Use one-shot long-context editing over the whole document

Rejected because: Evaluations found it missed large portions of long documents and suffered from lost-in-the-middle effects.

“our evaluations found that one-shot edits on these long documents tend to miss large portions of the document when thorough document-wide edits are needed.”article, stated

Rely only on human expert evaluation

Rejected because: The number of experiments exceeded human evaluation capacity, so Harvey combined automated and expert-led evaluation.

“The number of experiments we wanted to run quickly exceeded our human evaluation capacity.”article, stated

Patterns

multi-agent-orchestration (agent)

An orchestrator model plans document-wide work and delegates bounded chunks to subagents.

“we introduced an orchestrator-subagent architecture.”article, stated

context-compaction (context)

The system decomposes long legal documents into bounded chunks so subagents can focus on smaller contexts while the orchestrator maintains global constraints.

“Subagents receive precise, localized instructions and achieve thoroughness by only having to consider a small portion of the document.”article, stated

structured-output-contract (document-engineering)

The model proposes text-level edits that are deterministically mapped back into precise OOXML/Word mutations.

“then deterministically translate those edits back into precise OOXML mutations that preserve styles and structure.”article, stated

eval-driven-development (evaluation)

Harvey used automated and expert-led evaluation to compare model roles, tracked-change representations, and implementation approaches.

“we were able to quickly generate A/B experiments and validate different approaches to the implementation.”article, stated

Tradeoffs

Separate legal reasoning from OOXML mutation

Chose Natural-language edit proposal plus deterministic OOXML application over Direct model-generated OOXML.

Rationale: This preserves Word structure and avoids forcing the model to reason and emit valid XML simultaneously.

“Our approach separates concerns by creating a reversible mapping between OOXML objects and their natural-language content.”article, stated

Use orchestrator-subagent decomposition

Chose Global planner plus localized subagents over One monolithic long-context edit.

Rationale: Chunked subagents improve thoroughness and latency/cost behavior for document-wide changes.

“Treating a 200-page M&A agreement as one monolith also increases latency and cost without guaranteeing better recall of edit obligations.”article, stated

Blend automated and expert-led evaluation

Chose Directional automated metrics plus lawyer expertise over Pure human review for every experiment.

Rationale: Human expert review alone could not keep up with the number of experiments.

“To maintain development velocity while holding a high quality bar, we had to get clever about how we combined”article, stated

Gotchas (what bit them)

Raw OOXML is a bad model interface for legal reasoning.

Root cause: OOXML is verbose, interdependent, and schema-sensitive while LLMs are trained primarily on natural language.

Resolution: Use a reversible natural-language representation and deterministic OOXML application.

“When asked to simultaneously “do legal reasoning about this complex edit request” and “parse and emit XML,” performance on both tasks tends to regress.”article, stated

Long-context models still under-edit the middle of legal documents.

Root cause: Position bias/lost-in-the-middle causes over-attention to beginning/end and partial coverage.

Resolution: Use orchestrator-subagent decomposition into bounded chunks.

“Models over-attend to the beginning or end of the context and under-edit the middle, which yields partial coverage instead of a comprehensive pass.”article, stated

Model-choice experimentation can exceed expert review capacity.

Root cause: A multi-model architecture creates many latency/cost/quality combinations to evaluate.

Resolution: Combine automated directional metrics with lawyer expert review.

“we had a wide variety of model choices to evaluate for each role in the orchestrator-subagent architecture–each with their own tradeoffs on latency, cost, and quality.”article, stated

Evaluation

Harvey used domain experts, product owners, and engineers to define quantitative and qualitative metrics, then generated automated directional signals and A/B experiments with legal expert collaboration.

Metrics: Percentage of body elements modified · Alignment with user request · No regression on previous dataset · Improvement on redline-referencing queries · Large input-set output generation under five minutes

“This included quantitative metrics, such as the percentage of body elements modified by the algorithm, and qualitative metrics, such as how well the algorithm’s output aligned with the user’s request.”article, stated
“Automated offline evaluation confirmed that there was no regression on the previous dataset, and demonstrated a clear improvement over baseline performance on queries that referred to redlines in the input document.”article, stated

Outcomes

The architecture targets 100+ page legal documents, 200-page M&A agreements, and edit requests that can require thousands of changes.

“transforming hours of manual effort into a single seamless interaction with Harvey.”article, stated
“This launch turns complex, hours-long legal editing tasks into cohesive one-query interactions.”article, stated