latent.agents.guided.context_builder¶
Prompt assembly and guideline matching strategies for GuidedAgent.
Functions¶
batch_match_guidelines¶
batch_match_guidelines(guidelines: list[Guideline], messages: list[Message], model: str) -> list[GuidelineMatch]
Single structured-output LLM call to evaluate all guideline conditions.
build_system_prompt¶
build_system_prompt(base_prompt: str, matched_guidelines: list[Guideline], mode: str = 'fluid', glossary: Glossary | None = None, messages: list[Message] | None = None, journey_state: JourneyState | None = None, canned_responses: list[CannedResponse] | None = None) -> str
Assemble the full system prompt for a single turn.
embedding_match_guidelines¶
embedding_match_guidelines(guidelines: list[Guideline], messages: list[Message], model: str, threshold: float = 0.75, guideline_embeddings: dict[str, list[float]] | None = None) -> list[GuidelineMatch]
Semantic similarity matching using litellm embeddings.
match_always¶
Include all guidelines every turn — no LLM call.
resolve_guidelines¶
Apply exclusion rules and sort active guidelines by priority (descending).
Exclusions are applied in priority order: a high-priority guideline excludes lower-priority ones, but a low-priority guideline cannot exclude a higher-priority guideline that has already been accepted.