> Source: https://builder.ema.ai/v2/agent-reference/document-writer
> Title: Document Writer Agent

# Document Writer Agent

The Document Writer agent generates well-structured, professional documents from the instructions you give it. When a step in a workflow needs to produce a real document — a report, a brief, a policy draft, meeting notes — the Document Writer creates it as structured HTML, can revise it section by section, and keeps a version history you can refer back to.

In the AI Employee (AIE) builder, the Document Writer Agent appears in the **Generation** group of the agent library. It is a preset built on the `document_agent` base type, shipped with instructions already written for document generation, so you can drop it onto a workflow and configure only what you need.

## When to use it

Reach for the Document Writer when a workflow needs to _produce a document as its output_, rather than answer a question or pull data out of text:

-   Draft a structured report or summary from upstream research.
-   Generate a first-draft document — a proposal, a policy, an onboarding guide — that a person will review.
-   Revise an existing document section by section across a multi-step conversation.

If you only need a short text reply, use the [Respond Agent](/builder/v2/agent-reference/respond). If you need to answer a question from your knowledge base, use [Knowledge Search](/builder/v2/agent-reference/knowledge-search) or [Search and Respond](/builder/v2/agent-reference/search-and-respond). If you need machine-readable JSON, use [Extraction](/builder/v2/agent-reference/extraction).

## How it works

The Document Writer runs on the shared agentic loop (see the [Agent Reference overview](/builder/v2/agent-reference#the-shared-execution-model)), with a document-specific instruction block appended to your Instructions. It has three built-in document tools available in its loop:

-   **`create_document`** — produces a new document. The agent is instructed to emit well-structured, semantic HTML: an `<h1>` title, `<h2>`/`<h3>` headings, and every major section wrapped in `<section id="...">` tags with descriptive IDs (for example `<section id="introduction">`).
-   **`update_document`** — revises an existing document. The agent first calls `get_document` to read the current content, then applies a change. It can target a single section by passing the section's `id` (the server merges the new HTML into the full document) or replace the whole document at once. Sections that weren't asked to change are preserved.
-   **`get_document`** — reads the current content of a document. This is read-only and always runs before an update.

The agent also behaves conversationally: if the request is a question or chat rather than a document operation, it replies in text without touching the document tools, and after creating or updating a document it returns a brief plain-language summary of what it did. When knowledge bases are attached, it can call `search_knowledge_base` to gather context before writing, and it can call `ask_human` to ask a clarifying question when a request is vague (unless HITL is turned off on the node).

## Configuration

The Document Writer ships with its instructions pre-filled and exposes these advanced settings in the builder:

Setting

Purpose

Instructions

The system prompt. Ships pre-filled with document-writing guidance; edit it to set the document's purpose, tone, and structure. Supports `{{input.<field>}}` placeholders.

LLM configuration

The model and generation settings, served through EmaFusion™.

Knowledge bases

Optional. When attached, the agent can research with `search_knowledge_base` before writing.

HITL

Optional human-in-the-loop. When enabled, the agent can pause to ask a clarifying question via `ask_human`.

The underlying `document_agent` base type needs **no `type_config`** — its document instructions are self-contained. The default Instructions are:

```text
You are a document writer. Generate well-structured, professional documents
based on the provided instructions. Use clear headings, organized sections,
and appropriate formatting.

User instructions: {{input.instructions}}
```

> [INFO]
> **Dispatch-only type.** `document_agent` runs on the shared engine but is not part of the live/deprecated catalog lifecycle — it has no platform-managed versions and no publish-time version validation. See [The agent-type catalog](/builder/v2/agent-reference#the-agent-type-catalog).

## Inputs and output

The preset declares one input field, `instructions` — the text describing what to write. You wire it on the node through `input_mapping`, the same way as every other agent.

**Input**

```json
{ "instructions": "Write a one-page onboarding guide for new support agents, covering the ticketing tool, escalation paths, and the on-call rotation." }
```

**Output**

The agent's primary `output` is its conversational reply — a short, plain-language summary of what it produced. The documents it created or edited are surfaced separately in a `document_operations` array, so a downstream node (or the UI) can link to the result without parsing the model's text:

```json
{
  "output": "I've drafted a one-page onboarding guide with sections for the ticketing tool, escalation paths, and the on-call rotation.",
  "document_operations": [
    {
      "type": "created",
      "document_id": "doc_a1b2c3",
      "title": "Support Agent Onboarding Guide",
      "version_number": 1
    }
  ]
}
```

Each entry in `document_operations` records one create or update:

Field

Meaning

`type`

`"created"` or `"updated"`.

`document_id`

Stable ID of the document. Use this to reference or fetch it downstream.

`title`

The document's title.

`version_number`

The version this operation produced. Each edit increments it, preserving the history.

`change_description`

For updates, a brief summary of the edit.

`section_id`

For section-scoped updates, the `id` of the section that changed.

In the builder, a Document Writer node exposes `document_id` and `document_url` output ports so you can pass the result to a publish step or a later node.

## Example

A workflow that turns a research step into a polished brief:

1.  A [Search and Respond](/builder/v2/agent-reference/search-and-respond) node researches a topic from the knowledge base.
2.  A **Document Writer** node takes that research on its `instructions` input and produces a structured HTML brief, returning the new document's `document_id`.
3.  A publish node delivers the document to the requester.

## What's next

-   [Agent Reference overview](/builder/v2/agent-reference) — the type model, catalog, and shared execution engine.
-   [Respond Agent](/builder/v2/agent-reference/respond) — generate a short text reply from the system prompt and LLM.
-   [Knowledge Search Agent](/builder/v2/agent-reference/knowledge-search) — retrieve and answer from your knowledge base.
