Repository navigation
fix(live): persona replies keep the thread, follow the recipient's language, and handle refusals - #20
Merged
Conversation
…nguage, and handle refusals
- The persona prompt now includes the original lure (HTML stripped, GoPhish
{{.URL}} shown as [link]); previously the model was asked to continue a
thread it could not see.
- History holds only what the recipient saw: their messages and replies that
were actually sent (no unapproved or discarded drafts).
- The persona answers in the language the recipient wrote in, falling back to
the campaign language.
- A model refusal or empty output is retried once; if it persists, an empty
draft marked persona_declined is queued so the reviewer writes the turn,
instead of queueing the refusal text or a blank email.
- Approving a draft with an empty body is rejected (400).
- Review queue includes the campaign name and the message being answered;
Reply Review page localized (EN/ID) and shows the declined state.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 31, 2026
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.
Stacked on #19.
Problem
Reply Review showed persona drafts that were refusals ("I cannot generate persuasive phishing…") or completely empty. Causes:
Changes
lure_text()turnsbody_htmlinto plain text ({{.URL}}→[link], other template tags removed) and the system prompt includes it with the subject. Prompt states the real context: authorized exercise run by the recipient's organization, human-reviewed before sending, recipient debriefed, nothing collected.detect_language()on the recipient's message (ID/EN word heuristics) overrides the campaign language when clear.is_refusal()(empty, or EN/ID refusal phrasing; tuned to not flag "I can't wait…" / "I'm sorry for the delay…") → retry once → otherwise queue an empty draft withpersona_declined: true.campaign_nameandin_reply_to; Reply Review page shows them, flags "AI did not draft", disables approve until there is text, and is localized EN/ID. Campaign conversation panel shows the declined note instead of a blank bubble.This does not try to get around provider safety behaviour; the fallback is a human writing the turn (G8), or a local model.
Testing
pytest: 250 passed (refusal/language/lure parsing, prompt contents, retry, persistent refusal, history filtering, empty-approve guard, review context)ruffclean;CI=true craco buildOK🤖 Generated with Claude Code