Repository navigation
Description
Bug
Content opportunity titles/descriptions sometimes reference prompts by their internal bracketed index instead of their text. Real example shape (localized to the brand's language):
"For Prompt [0] specifically, there is 32,880 monthly AI volume and 0% visibility. A category guide with technical comparisons should be created…"
A user reading the opportunity card has no idea what "Prompt [0]" means — the index is an internal artifact.
Root cause
Both opportunity-generation paths label the prompt list with [${i}] so the model can return relatedPromptIndex (which we map back to prompt_id):
- https://github.com/ansvisor/ansvisor/blob/main/server/src/workers/content-worker.js —
userPromptbuilds[${i}] "${p.text}" | …lines, schema hasrelatedPromptIndex, and the index is resolved toprompt_idwhen saving. - https://github.com/ansvisor/ansvisor/blob/main/server/src/lib/opportunity-generator.js — same
[${i}]labeling andrelatedPromptIndexschema field.
Nothing tells the model the index exists only for relatedPromptIndex, so it occasionally uses it in the user-facing prose.
Proposed fix (prompt-level, no logic changes)
-
Add a rule to the system prompt in both files:
- The bracketed [N] indexes in the prompt data exist ONLY for the relatedPromptIndex field. NEVER mention an index like "[0]" or "Prompt 3" in titles or descriptions — refer to the prompt by quoting or paraphrasing its actual text/topic instead. -
Harden the
descriptionfield's.describe()in both zod schemas, e.g.:'A 1-2 sentence explanation of why this action matters, referencing specific metrics. Never reference prompts by their bracketed index — name the topic or quote the prompt text.'
Stating it in both the system prompt and the field description matters: with generateObject, models weight per-field schema descriptions heavily, and the system-prompt rule alone doesn't reliably stop the leak.
Regex post-processing was considered and rejected: descriptions are generated in the brand's language, so index-mention patterns vary too much to strip safely.
Notes
- Existing bad rows self-heal: the worker deletes
status='new'opportunities and regenerates on each run, so descriptions are clean after the first content run following the fix.
Acceptance criteria
- Generated titles/descriptions never contain bracketed indexes or "Prompt N" references, across languages.
relatedPromptIndexkeeps working (opportunities still link to the rightprompt_id).- Both generation paths (
content-worker.jsandopportunity-generator.js) carry the new rules.
Activity
fix(opportunities): prevent prompt index leak in generated titles/des…