Skip to content

Fix: strategic_questions block not removed when ExplorationPlanner suggestions unavailable#5

Open
francisjervis wants to merge 2 commits into
SALT-NLP:mainfrom
francisjervis:fix/strategic-questions-unfilled-placeholder
Open

Fix: strategic_questions block not removed when ExplorationPlanner suggestions unavailable#5
francisjervis wants to merge 2 commits into
SALT-NLP:mainfrom
francisjervis:fix/strategic-questions-unfilled-placeholder

Conversation

@francisjervis

Copy link
Copy Markdown

Problem

get_prompt("normal") performs a two-stage template expansion:

  1. Stage 1 (inside get_prompt): format_prompt(INTERVIEW_PROMPT, {...}) replaces the uppercase {STRATEGIC_QUESTIONS} token with the STRATEGIC_QUESTIONS string, which itself contains the lowercase placeholder {strategic_questions}.

  2. Stage 2 (inside _get_prompt): format_prompt(main_prompt, format_params) fills in runtime values.

The staleness-removal code ran between these two stages:

main_prompt = main_prompt.replace("\n{STRATEGIC_QUESTIONS}\n", "\n")

But by then the uppercase token is already gone — this replace is a no-op. The lowercase {strategic_questions} placeholder remains in the prompt. When the strategic_questions key is absent from format_params (because _should_include_strategic_questions() returned False), format_prompt's missing-key fallback re-inserts it verbatim, and the LLM receives the literal string {strategic_questions} inside the <strategic_questions> block.

This affects every turn before the ExplorationPlanner completes its first run (turns 2–3 by default) and any future stale periods.

Fix

Replace the no-op string replace with re.sub that strips the already-expanded <strategic_questions>…</strategic_questions> XML block:

main_prompt = re.sub(
    r"\n<strategic_questions>.*?</strategic_questions>",
    "",
    main_prompt,
    flags=re.DOTALL,
)

re is already imported in interviewer.py. No other files are changed.

Verification

Confirmed with a unit test that:

  • After the fix, the block is completely absent from the prompt when suggestions are unavailable
  • When suggestions are available (key present in format_params), the block is still filled correctly

🤖 Generated with Claude Code

francisjervis and others added 2 commits May 27, 2026 14:32
…navailable

get_prompt("normal") performs a first-stage format_prompt that expands the
uppercase {STRATEGIC_QUESTIONS} token in INTERVIEW_PROMPT into the full
<strategic_questions>…{strategic_questions}…</strategic_questions> block.

The previous staleness-removal code called:
  main_prompt.replace("\n{STRATEGIC_QUESTIONS}\n", "\n")
But by that point the uppercase token is already gone, making this a no-op.
The lowercase {strategic_questions} placeholder was then left in the prompt
and, because format_prompt re-inserts missing keys verbatim, the LLM received
the literal string "{strategic_questions}" in every turn before the
ExplorationPlanner completed its first run (turns 2-3) and during any stale
period thereafter.

Fix: use re.sub to strip the already-expanded XML block instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a recovery pass using clean_malformed_xml before failing, and
return an empty list instead of raising on parse error. Prevents
AgendaManager._process_qa_pair tasks from dying silently and leaving
memory/subtopic-coverage state partially un-updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant