Skip to content

preamble

preamble

Dynamic, context-aware preamble building for Marianne-orchestrated agents.

Generates preambles that tell agents who they are, where they are in the concert, and what success looks like. Replaces the static 5-rule warning label that was previously hardcoded in ClaudeCliBackend.

Functions

build_preamble

build_preamble(sheet_num, total_sheets, workspace, retry_count=0, is_parallel=False)

Build a context-aware preamble for a Marianne-orchestrated agent.

Parameters:

Name Type Description Default
sheet_num int

Current sheet number (1-indexed).

required
total_sheets int

Total number of sheets in the concert.

required
workspace Path

Workspace directory path.

required
retry_count int

Number of previous failed attempts (0 = first run).

0
is_parallel bool

Whether parallel execution is enabled.

False

Returns:

Type Description
str

Preamble string wrapped in <marianne-preamble> tags.

Source code in src/marianne/prompts/preamble.py
def build_preamble(
    sheet_num: int,
    total_sheets: int,
    workspace: Path,
    retry_count: int = 0,
    is_parallel: bool = False,
) -> str:
    """Build a context-aware preamble for a Marianne-orchestrated agent.

    Args:
        sheet_num: Current sheet number (1-indexed).
        total_sheets: Total number of sheets in the concert.
        workspace: Workspace directory path.
        retry_count: Number of previous failed attempts (0 = first run).
        is_parallel: Whether parallel execution is enabled.

    Returns:
        Preamble string wrapped in ``<marianne-preamble>`` tags.
    """
    if retry_count > 0:
        return _build_retry_preamble(
            sheet_num, total_sheets, workspace, retry_count,
        )
    return _build_first_run_preamble(
        sheet_num, total_sheets, workspace, is_parallel,
    )