Fix: strategic_questions block not removed when ExplorationPlanner suggestions unavailable#5
Open
francisjervis wants to merge 2 commits into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
get_prompt("normal")performs a two-stage template expansion:Stage 1 (inside
get_prompt):format_prompt(INTERVIEW_PROMPT, {...})replaces the uppercase{STRATEGIC_QUESTIONS}token with theSTRATEGIC_QUESTIONSstring, which itself contains the lowercase placeholder{strategic_questions}.Stage 2 (inside
_get_prompt):format_prompt(main_prompt, format_params)fills in runtime values.The staleness-removal code ran between these two stages:
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 thestrategic_questionskey is absent fromformat_params(because_should_include_strategic_questions()returnedFalse),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.subthat strips the already-expanded<strategic_questions>…</strategic_questions>XML block:reis already imported ininterviewer.py. No other files are changed.Verification
Confirmed with a unit test that:
format_params), the block is still filled correctly🤖 Generated with Claude Code