Skip to content

Content opportunity descriptions leak internal prompt indexes like "Prompt [0]" #424

Closed

Description

@gkhngyk

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):

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)

  1. 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.
    
  2. Harden the description field'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.
  • relatedPromptIndex keeps working (opportunities still link to the right prompt_id).
  • Both generation paths (content-worker.js and opportunity-generator.js) carry the new rules.

Activity

  1. added
    bug
    good first issue
    on Jul 14, 2026
  2. added a commit that references this issue on Jul 16, 2026
    ba89a84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions