> For the complete documentation index, see [llms.txt](/llms.txt). Every page on this site is also available as markdown at `<path>.md`.

# Prompts

Layered prompt rendering. `layered_prompt(...)` produces deterministic text
and a SHA-256 cache key derived from the rendered output.

<span id="flowai_harness.prompts.layered_prompt"></span>

## `layered_prompt`

`layered_prompt(*, identity: 'str', communication: 'TextSection' = None, operational_rules: 'TextSection' = None, tools: 'Iterable[ToolPromptInput] | None' = None, domain_knowledge: 'StructuredSection' = None, safety: 'TextSection' = None, output_format: 'StructuredSection' = None, examples: 'StructuredSection' = None) -> 'LayeredPrompt'`

<table>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>identity</code></td>
<td><code>str</code></td>
<td>required</td>
</tr>
<tr>
<td><code>communication</code></td>
<td><code>TextSection</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>operational_rules</code></td>
<td><code>TextSection</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>tools</code></td>
<td><code>Iterable[ToolPromptInput] | None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>domain_knowledge</code></td>
<td><code>StructuredSection</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>safety</code></td>
<td><code>TextSection</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>output_format</code></td>
<td><code>StructuredSection</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>examples</code></td>
<td><code>StructuredSection</code></td>
<td><code>None</code></td>
</tr>
</tbody>
</table>

<p><strong>Returns:</strong> <code>LayeredPrompt</code></p>

Build the sanctioned Flow AI layered prompt shape.

The returned text is deterministic for identical inputs. The cache key is
the SHA-256 hash of the rendered prompt text, so changing any rendered
section changes the key. Empty sections are omitted.

Args:
    identity: Who the agent is. Required; string or sequence of strings
        rendered as a bullet list.
    communication: Tone and audience guidance; string or sequence of
        strings.
    operational_rules: Behavioral rules; string or sequence of strings.
    tools: Tool rows rendered as a Markdown table: ``ToolSpec`` values,
        mappings with ``name`` / ``description`` / ``approval``, or
        plain names. Duplicate names keep the first row.
    domain_knowledge: Business context; a string, or any
        JSON-serializable structure rendered as a JSON code block.
    safety: Safety constraints; string or sequence of strings.
    output_format: Expected output shape; string or JSON-serializable
        structure.
    examples: Worked examples; string or JSON-serializable structure.

Returns:
    A ``LayeredPrompt`` with the rendered text and its deterministic
    cache key.

Raises:
    TypeError: If a text section is not a string or sequence of strings,
        or a structured section contains values that cannot be rendered
        as JSON.

<span id="flowai_harness.prompts.LayeredPrompt"></span>

## `LayeredPrompt`

`LayeredPrompt(text: 'str', cache_key: 'str') -> None`

<table>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>text</code></td>
<td><code>str</code></td>
<td>required</td>
</tr>
<tr>
<td><code>cache_key</code></td>
<td><code>str</code></td>
<td>required</td>
</tr>
</tbody>
</table>

<p><strong>Returns:</strong> <code>None</code></p>

Rendered layered prompt plus its deterministic prompt cache key.
