structured_writing tool is designed for generating long-form, coherent content that requires a specific structure or outline. Unlike standard chat responses which are often linear and limited in length, this tool can orchestrate the creation of complex documents like reports, blog posts, white papers, or technical specifications.
It works by taking a high-level intent and a structured plan, then systematically generating content for each section, maintaining context and consistency throughout the document.
When to Use This Tool
Usestructured_writing when you need to:
- Draft Long Documents: Create content that exceeds the typical output limits of a single LLM call.
- Follow a Specific Outline: Ensure the output adheres strictly to a predefined structure (e.g., Introduction -> Methodology -> Results -> Conclusion).
- Maintain Consistency: Generate multiple sections that need to reference each other or maintain a consistent tone.
- Collaborate with Sub-Agents: Delegate specific sections to specialized sub-agents (e.g., a “Data Analyst” agent for the results section).
Input Parameters
The tool accepts the following parameters:| Parameter | Type | Required | Description |
|---|---|---|---|
intent | string | Yes | The overall goal of the writing. This guides the tone, style, and content generation for all parts. |
structured_plan | object | Yes* | A recursive JSON object detailing the structure of the document. Each part can contain its own parts array, allowing for deeply nested sections and subsections. See “Plan Structure” below. |
plan_document_id | string | Yes* | Alternatively, the UUID of a JSON document containing the structured_plan. |
execution_mode | string | No | sequential (default) or parallel. Sequential allows for memory/context between sections; parallel is faster but sections are independent. |
memory_mode | string | No | classic (default), specific, or none. Controls how context is passed between sections in sequential mode. |
structured_plan or plan_document_id must be provided.
Plan Structure
Thestructured_plan is a recursive JSON object where each node represents a section of the document. This allows you to create complex hierarchies with chapters, sections, and subsections.
Output Structure
The tool returns the original plan enriched with the generated content.| Field | Description |
|---|---|
full_text | The complete, concatenated text of the generated document, formatted with Markdown headers. |
plan | The original plan object, but each part now includes a written_content field containing the generated text for that specific section. It also includes metadata like id, depth, and potentially sub_session_id if an agent was used. |
execution_id | The unique identifier for this tool execution. |
Example Usage
Scenario: Writing a Quarterly Report
Input:Advanced Features
1. Sequential vs. Parallel Execution
- Sequential: Writes sections one by one. The context (what was written previously) is passed to the next step. Best for narratives where flow and consistency are critical.
- Parallel: Writes all sections simultaneously. Much faster, but sections cannot reference each other. Best for encyclopedic content or independent summaries.
2. Sub-Agent Delegation
You can assign specific sections to specialized agents by adding anagent_id to a part in the plan.
3. Memory Modes
Insequential mode, you can control how much context is retained:
- Classic: Summarizes the history when it gets too long. Good balance.
- Specific: Re-analyzes the entire history for each new section to find relevant context. Slower but higher quality for complex documents.
- None: No context is passed between sections (acts like parallel but runs sequentially).

