fix(retain): inject retain_mission into verbose extraction mode (#745) (#754)

Verbose mode was the only extraction mode that skipped injecting the
retain_mission FOCUS section into its prompt template. Users who set a
retain_mission got no filtering when using verbose mode.
This commit is contained in:
Nicolò Boschi 2026-03-30 11:36:36 +02:00 committed by GitHub
parent ecf16ea1e6
commit d2965e64e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View file

@ -616,7 +616,7 @@ VERBOSE_FACT_EXTRACTION_PROMPT = """Extract facts from text into structured form
LANGUAGE: MANDATORY Detect the language of the input text and produce ALL output in that EXACT same language. You are STRICTLY FORBIDDEN from translating or switching to any other language. Every single word of your output must be in the same language as the input. Do NOT output in a different language under any circumstance.
{retain_mission_section}
FACT FORMAT - ALL FIVE DIMENSIONS REQUIRED - MAXIMUM VERBOSITY
@ -827,7 +827,9 @@ def _build_extraction_prompt_and_schema(config) -> tuple[str, type]:
custom_instructions=config.retain_custom_instructions,
)
elif extraction_mode == "verbose":
prompt = VERBOSE_FACT_EXTRACTION_PROMPT
prompt = VERBOSE_FACT_EXTRACTION_PROMPT.format(
retain_mission_section=retain_mission_section,
)
elif extraction_mode == "verbatim":
prompt = VERBATIM_FACT_EXTRACTION_PROMPT.format(
retain_mission_section=retain_mission_section,

View file

@ -2612,11 +2612,11 @@ def test_retain_mission_injected_into_prompt():
assert spec in prompt
assert "FOCUS" in prompt
# retain_mission is present regardless of extraction mode (verbose has its own template, no spec injection)
# retain_mission is injected into verbose mode as well
config.retain_extraction_mode = "verbose"
prompt_verbose, _ = _build_extraction_prompt_and_schema(config)
# verbose uses its own template - spec not injected there
assert spec not in prompt_verbose
assert spec in prompt_verbose
assert "FOCUS" in prompt_verbose
def test_retain_mission_absent_when_not_set():