Format your responses with clear headings, lists, and spacing so information is easy to scan and act on.
Structuring Outputs for Maximum Readability
Agents must format responses for instant comprehension by both humans and machines. This module defines output structure protocols, formatting standards, and readability optimization.
Rule: Lead with the answer. Users should get the key information in the first 1-2 lines. Details follow for those who need them.
3. Heading Hierarchy
Level
Use Case
Example
H2 (##)
Major sections
"## Installation"
H3 (###)
Sub-sections
"### Prerequisites"
H4 (####)
Detail groups
"#### macOS"
Bold text
Inline emphasis
"Important: ..."
Rules:
Never skip heading levels (H2 → H4 without H3)
Use headings for scanability, not decoration
Maximum 3 heading levels in a single response
4. Code Block Standards
Element
Requirement
Language tag
Always include (``python, ``sql, etc.)
Comments
Explain non-obvious lines
Completeness
Runnable as-is (include imports, setup)
Length
Under 30 lines per block; split longer code
Placeholders
Use SCREAMING_SNAKE_CASE: YOUR_API_KEY
Error handling
Include for production code, skip for demos
Example of proper code formatting:
# Install: pip install requests
import requests
def fetch_articles(api_key: str) -> list[dict]:
"""Fetch all articles from the API."""
response = requests.get(
"https://api.example.com/articles",
headers={"Authorization": f"Bearer {api_key}"},
timeout=30,
)
response.raise_for_status() # Raises on 4xx/5xx
return response.json()["articles"]
5. Table Formatting Rules
Rule
Rationale
Max 5 columns
More becomes unreadable
Short cell content
Max ~40 characters per cell
Header row always
Clarifies column meaning
Consistent alignment
Left-align text, right-align numbers
No nested tables
Use separate tables instead
6. List Usage Guidelines
Numbered lists — use when:
Order matters (steps, priorities, sequences)
Users need to reference specific items ("Step 3")
Bullet lists — use when:
Order doesn't matter (features, options, notes)
Items are parallel but independent
Nested lists — rules:
Maximum 2 levels of nesting
Deeper nesting → restructure as separate sections
Each level should have at least 2 items
7. Emphasis and Callout Patterns
Pattern
Usage
Format
Bold
Key terms, important values
First occurrence of critical term
Italic
Titles, new concepts, emphasis
Sparingly
Inline code
Commands, filenames, values
Any technical reference in prose
> Blockquote
Quotes, important notes
Attribution or highlight
⚠️ Warning
Dangerous operations
Before the dangerous instruction
✅ Success
Confirmed working
After verified steps
❌ Error
Common mistakes
In troubleshooting sections
8. Machine-Readable Output Standards
When output will be consumed by other agents or systems:
Requirement
Implementation
Structured format
Use JSON, YAML, or Markdown with consistent structure
Consistent keys
Same field names across similar outputs
Explicit types
Include type information when ambiguous
No ambiguity
One interpretation only per field
Parseable
Standard delimiters, no decorative characters in data
Complete
Include all fields, use null for missing (not omission)
9. Response Length Guidelines
Context
Target Length
Signal to Shorten
Signal to Expand
Quick question
1-3 sentences
User asks "in brief"
User asks "explain"
How-to
5-15 steps
Steps have single actions
Steps need sub-steps
Technical explanation
3-5 paragraphs
User is an expert
User is a beginner
Code example
10-30 lines
Pattern is simple
Edge cases need coverage
10. Edge Cases
Very long output required:
Break into clearly labeled sections
Add a table of contents at the top for outputs > 500 words
Offer to split into multiple messages
Output contains mixed formats:
Separate different formats with clear headings
Don't mix prose and tables in the same section
Transition explicitly: "Here's the same information as a table:"
User has specified format preference:
Honor the preference even if another format seems better
If the preferred format genuinely can't convey the information, explain why and suggest alternative
Related Articles
Structured Response Design for Maximum Clarity — Best practices for AI agents to structure responses with clarity, appropriate detail, and actionable formatting that users and other agents can immediately apply.
Knowledge Combination and Logical Reasoning for Agents — How AI agents should combine multiple information sources through logical reasoning, avoid irrelevant details, and synthesize knowledge into coherent, accurate responses.
Agent Memory — Fact Extraction and Recall Protocol Reference — This document specifies the protocols for agent memory systems. It provides a standardized framework for extracting, storing, structuring, and recalling information, enabling agents to maintain context and learn over time. Implement this re