Questions: 300 characters, refused when they look like prompt injection
CI / test (push) Successful in 2m3s
CI / build (push) Skipped
CI / deploy (push) Skipped

Three layers for the text users write into a prompt (questions about an
analysis, tarot questions):
- analysis_prompt::guard cleans it (controls, zero-width characters,
  spaces, empty lines) and refuses links, tags, code fences, chat role
  labels, more than 6 lines and phrases that try to change the model's
  instructions (Hungarian and English, accent-insensitive). The check runs
  before any unit is spent; refusals are logged without the text.
- The prompt puts the question (and earlier ones) between <kerdes> tags,
  with anything that could close the tag neutralized.
- The system prompts say the tagged text is data, not instructions, and
  not to quote or summarize the rules (the tarot prompts now say it too).
The question limit drops from 600 to 300 characters (as for tarot), with a
counter always shown under the box.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-23 11:32:38 +00:00
co-authored by Claude Opus 5.5
parent f8abdac790
commit 3269aaaa35
9 changed files with 320 additions and 30 deletions
@@ -12,7 +12,8 @@ import { RegenerateButton } from "./RegenerateButton";
import { RetryNotice } from "./RetryNotice";
import { Paragraphs } from "./Rich";
const MAX_CHARS = 600;
/** The longest question (the backend checks it too: QUESTION_MAX_CHARS). */
const MAX_CHARS = 300;
export const QUESTION_TEXTS = {
natal: {
@@ -221,7 +222,9 @@ export function AnalysisQuestions({
</button>
<span className="hint">
{waiting ? "Várd meg az előző válaszát." : `Még ${left} kérdésed van.`}{" "}
{text.length > MAX_CHARS - 100 && `${text.length}/${MAX_CHARS}`}
<span className="num" aria-live="polite">
· {text.length}/{MAX_CHARS}
</span>
</span>
</div>
{error && (
@@ -207,7 +207,10 @@ export function TarotTable({
onChange={(e) => setQuestion(e.target.value)}
/>
<span className="hint">
Nyitott kérdés működik a legjobban („mire figyeljek”, „mit tanulhatok”), nem igen–nem kérdés.
Nyitott kérdés működik a legjobban („mire figyeljek”, „mit tanulhatok”), nem igen–nem kérdés.{" "}
<span className="num">
{question.length}/{TAROT_QUESTION_MAX}
</span>
</span>
</div>
<div className="form-actions">