Implementation:Diagram of thought Diagram of thought Node Edge Status Protocol Config
| Knowledge Sources | |
|---|---|
| Domains | Protocol_Design, Configuration, Formal_Verification |
| Last Updated | 2026-02-14 04:30 GMT |
Overview
Concrete pattern for including or excluding @node, @edge, and @status typed record instructions in a DoT prompt and configuring enforcement levels.
Description
This implementation pattern modifies a DoT prompt to include or exclude the typed record instruction block and to configure the critic's @status enforcement level. In strict mode, the critic role is mandated to emit a @status record for every proposition it evaluates, ensuring a complete validation trace suitable for formal verification. In flexible mode, @status emission is encouraged but optional, allowing the critic to provide softer, natural language assessments without the overhead of mandatory structured records.
The pattern operates entirely through string manipulation of the prompt text. It appends the typed record instruction block when the protocol is enabled, and it adjusts the critic's behavioral instructions to reflect the chosen enforcement level. No external libraries or runtime dependencies are required.
Usage
Apply this pattern after role customization (e.g., after adjusting proposer, critic, or summarizer instructions for a specific domain) and before validation testing (e.g., before running the configured prompt against test problems to verify correct behavior). The configuration function takes a partially customized prompt and returns a fully configured prompt with protocol settings applied.
Code Reference
Source Location
- Repository: Diagram of Thought
- Files:
README.md:L68-72-- Typed record format specification (@node,@edge,@status)README.md:L61-- Protocol optionality statement ("optional for basic use but essential for formal guarantees")README.md:L101-102-- Strict and flexible mode descriptions
Signature
def configure_protocol(prompt: str, config: dict) -> str:
"""
Configure typed protocol settings in a DoT prompt.
Parameters
----------
prompt : str
A partially customized DoT prompt (role instructions already applied).
config : dict
Configuration dictionary with keys:
- "typed_protocol" (bool): Whether to append the @node/@edge/@status
instruction block.
- "rigor_level" (str): "strict" or "flexible". Controls the critic
@status mandate.
Returns
-------
str
The fully configured prompt with protocol settings applied.
"""
Import
# No external dependencies -- operates via string manipulation on the prompt text.
# The typed record block and critic mandates are string constants appended to or
# substituted within the prompt.
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| prompt | str | Yes | A partially customized DoT prompt with role instructions already in place. Expected to contain the critic behavioral text "Provide detailed natural language critiques" as the substitution anchor.
|
| config | dict | Yes | Configuration dictionary. Must contain "typed_protocol" (bool) and "rigor_level" (str, one of "strict" or "flexible").
|
Outputs
| Name | Type | Description |
|---|---|---|
| configured_prompt | str | Fully configured DoT prompt with typed record instructions appended (if enabled) and critic @status mandate set according to the chosen rigor level.
|
Usage Examples
Full Configuration Pattern
TYPED_RECORDS_BLOCK = """
When possible, interleave typed records for auditability:
@node id=<n> role={problem|proposer|critic|summarizer}
@edge src=<i> dst=<n> kind={use|critique|refine} (must have i < n)
@status target=<i> mark={validated|invalidated}
"""
STRICT_CRITIC_MANDATE = "You MUST emit a @status record for every proposition you evaluate."
FLEXIBLE_CRITIC_MANDATE = "When possible, emit a @status record to indicate your validation decision."
def configure_protocol(prompt: str, config: dict) -> str:
"""Configure typed protocol settings in a DoT prompt."""
if config["typed_protocol"]:
prompt += TYPED_RECORDS_BLOCK
if config["rigor_level"] == "strict":
prompt = prompt.replace(
"Provide detailed natural language critiques",
"Provide detailed natural language critiques. " + STRICT_CRITIC_MANDATE
)
else:
prompt = prompt.replace(
"Provide detailed natural language critiques",
"Provide detailed natural language critiques. " + FLEXIBLE_CRITIC_MANDATE
)
return prompt
Strict Mode for Mathematical Reasoning
# Load and customize the base prompt
with open("prompts/iterative-reasoner.md", "r") as f:
base_prompt = f.read()
# Enable full protocol with strict enforcement
math_config = {
"typed_protocol": True,
"rigor_level": "strict"
}
configured_prompt = configure_protocol(base_prompt, math_config)
# The prompt now includes the @node/@edge/@status block and the critic
# is mandated to emit @status for every proposition it evaluates.
Flexible Mode for Creative Tasks
# Enable protocol but with flexible enforcement
creative_config = {
"typed_protocol": True,
"rigor_level": "flexible"
}
configured_prompt = configure_protocol(base_prompt, creative_config)
# The prompt includes typed records but the critic is only encouraged
# (not required) to emit @status records.
Protocol Disabled for Simple Use
# Disable typed protocol entirely for basic, unaudited reasoning
simple_config = {
"typed_protocol": False,
"rigor_level": "flexible"
}
configured_prompt = configure_protocol(base_prompt, simple_config)
# The prompt relies only on XML role tags without typed records.
# Formal guarantees (acyclicity, completeness verification) are not available.