Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Diagram of thought Diagram of thought Role Block Editor

From Leeroopedia
Knowledge Sources
Domains Prompt_Engineering, Domain_Adaptation
Last Updated 2026-02-14 04:30 GMT

Overview

Role Block Editor is a concrete pattern for editing the proposer, critic, and summarizer instruction blocks within a DoT prompt template for domain-specific behavior.

Description

This implementation performs text modification of the three role instruction sections in the prompts/iterative-reasoner.md prompt template. Each role block has an Objective and Instructions section that can be customized independently:

  • Proposer block (L12-18): Contains the objective "Propose one or more reasoning steps towards solving the given problem" and instructions for generating clear propositions and building upon previous valid propositions.
  • Critic block (L20-26): Contains the objective "Critically evaluate the proposer's reasoning steps" and instructions for analyzing logical consistency and providing detailed critiques.
  • Summarizer block (L28-34): Contains the objective "Synthesize the validated propositions into a coherent chain-of-thought leading to the final solution" and instructions for reviewing the DAG, extracting valid steps, and determining completeness.

The editing operation is a targeted string replacement within each role's instruction text. The structural elements of the template -- the role headers, XML tag specifications, output format directives, process flow, formatting guidelines, and example interaction -- are preserved unchanged.

Usage

Role block editing is applied after selecting a base template and before protocol configuration. The typical workflow is:

  1. Load the base iterative-reasoner.md template.
  2. Apply domain-specific instruction replacements for each of the three roles.
  3. Load the modified template as the system prompt for the LLM session.

This step is a prerequisite for domain-specialized DoT reasoning and should be performed once per domain configuration.

Code Reference

Source Location

  • Repository: Diagram of Thought
  • File: prompts/iterative-reasoner.md
  • Lines: L12-18 (proposer), L20-26 (critic), L28-34 (summarizer)

Signature

def customize_roles(
    template: str,
    proposer_instructions: str,
    critic_instructions: str,
    summarizer_instructions: str
) -> str:
    """
    Modify the proposer, critic, and summarizer instruction blocks
    within a DoT prompt template for domain-specific behavior.

    Args:
        template: The base DoT prompt template text (contents of iterative-reasoner.md).
        proposer_instructions: Domain-specific instructions for the proposer role.
        critic_instructions: Domain-specific instructions for the critic role.
        summarizer_instructions: Domain-specific instructions for the summarizer role.

    Returns:
        Modified prompt template with customized role instructions.
    """

Import

# String manipulation only -- no special imports required.
# Load the base template from disk:
with open("prompts/iterative-reasoner.md", "r") as f:
    base_template = f.read()

I/O Contract

Inputs

Name Type Required Description
template str Yes Base DoT prompt template text (contents of prompts/iterative-reasoner.md)
proposer_instructions str Yes Domain-specific instructions to replace the proposer's default instruction text
critic_instructions str Yes Domain-specific instructions to replace the critic's default instruction text
summarizer_instructions str Yes Domain-specific instructions to replace the summarizer's default instruction text

Outputs

Name Type Description
modified_template str The prompt template with all three role instruction blocks replaced by the domain-specific instructions provided. The structural framework (role headers, XML tag specifications, process flow, formatting guidelines, example interaction) remains unchanged.

Usage Examples

Core Function

def customize_roles(
    template: str,
    proposer_instructions: str,
    critic_instructions: str,
    summarizer_instructions: str
) -> str:
    # Replace proposer instructions
    template = template.replace(
        "Generate clear and concise propositions that advance the reasoning process.",
        proposer_instructions
    )
    # Replace critic instructions
    template = template.replace(
        "Analyze the propositions for logical consistency and accuracy.",
        critic_instructions
    )
    # Replace summarizer instructions
    template = template.replace(
        "Review the DAG of propositions and critiques.",
        summarizer_instructions
    )
    return template

Mathematics Domain Customization

# Load the base template
with open("prompts/iterative-reasoner.md", "r") as f:
    base_template = f.read()

# Customize for formal mathematics
math_prompt = customize_roles(
    template=base_template,
    proposer_instructions="Propose formal mathematical proof steps. Each step must follow from axioms or previously validated steps.",
    critic_instructions="Check algebraic correctness, logical validity, and completeness. Verify each step is justified.",
    summarizer_instructions="Construct a formal proof from validated steps. Ensure logical chain is complete."
)

Code Review Domain Customization

# Customize for code review
code_prompt = customize_roles(
    template=base_template,
    proposer_instructions="Propose code improvements or identify potential issues. Reference specific lines.",
    critic_instructions="Verify proposed changes are correct, check for edge cases, security issues, and performance.",
    summarizer_instructions="Compile validated findings into an actionable code review summary."
)

Using the Customized Template

from openai import OpenAI

client = OpenAI()

# Use the math-customized prompt in a reasoning session
response = client.chat.completions.create(
    model="gpt-4",
    messages=[
        {"role": "system", "content": math_prompt},
        {"role": "user", "content": "Prove that the square root of 2 is irrational."}
    ]
)

print(response.choices[0].message.content)

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment