vibe.assistant.system_prompt_builder

System prompt building for the assistant.

PromptConfig

Configuration for system prompt building.

SystemPromptBuilder

Builds system prompts for the assistant.

Responsibilities: - Load and render system prompt templates - Format draft blocks as markdown - Determine unanswered questions - Extract Q&A pairs from history for consolidated draft strategy

__init__

__init__(config: PromptConfig) -> None

Initialize the builder with configuration.

Parameters:
  • config (PromptConfig) –

    PromptConfig containing template data and capability info

get_template

get_template(template_config: dict[str, Any] | None = None) -> Template

Get the system prompt Jinja template.

Parameters:
  • template_config (dict[str, Any] | None, default: None ) –

    Template configuration containing locale settings

Returns:
  • Template

    Jinja template for system prompt

build

build(current_state: dict[str, Any], draft_blocks: list[dict[str, Any]], unanswered_questions: list[dict[str, Any]], history: list[Message]) -> SystemMessage

Build the complete system prompt.

Parameters:
  • current_state (dict[str, Any]) –

    Current template variable values

  • draft_blocks (list[dict[str, Any]]) –

    List of draft block dicts with id and content

  • unanswered_questions (list[dict[str, Any]]) –

    List of unanswered question dicts (from QuestionSessionState)

  • history (list[Message]) –

    Conversation history (for Q&A extraction in consolidated mode)

Returns:

format_draft_blocks

format_draft_blocks(draft_blocks: list[dict[str, Any]]) -> str

Format draft blocks as markdown with semantic IDs.

Parameters:
  • draft_blocks (list[dict[str, Any]]) –

    List of block dicts with llm_id and content

Returns:
  • str

    Formatted markdown string

extract_qa_pairs

extract_qa_pairs(history: list[Message]) -> list[tuple[str, str]]

Extract question-answer pairs from conversation history.

Q&A pairs are extracted by matching tool responses to ask_* tool calls in the assistant messages.

Parameters:
  • history (list[Message]) –

    List of Message objects

Returns:
  • list[tuple[str, str]]

    List of (question, answer) tuples in chronological order

inject_draft

inject_draft(prompt_content: str, draft_blocks: list[dict[str, Any]]) -> str

Inject draft blocks content into system prompt for consolidated strategy.

Parameters:
  • prompt_content (str) –

    Original system prompt content

  • draft_blocks (list[dict[str, Any]]) –

    List of draft block dicts

Returns:
  • str

    System prompt with draft content injected