Repository navigation
Description
Description
Content opportunities are generated nightly (three per run) and appended to the list, and the list grows faster than anyone works through it. On production data, 98% of all opportunities are still new, and on a typical brand the most-loaded prompt carries 40–57 open opportunities. A user put it this way: the suggestions and briefs are great, but the Content Opportunities page gives so many actions for one prompt that it's easy to get lost.
The open opportunities on one prompt are mostly the same idea reworded night after night. For example, a single prompt collected 38 open opportunities over 32 nights, including:
- "The Startup's Guide to Open Source AEO"
- "The Startup Guide to Open Source AEO Benefits"
- "Startup Guide to Open Source AEO Strategies"
- "Whitepaper: The Startup's Guide to Open Source AEO"
Causes
Both generators are affected: the nightly one in server/src/lib/opportunity-generator.js and the one behind the Generate button in server/src/workers/content-worker.js.
- Only exact duplicates are caught. The nightly generator skips an opportunity only when an open one exists with the same
prompt_idand the same lowercased title. The model rewords the same idea each night, so near-duplicates always get through. The Generate-button path does no duplicate check at all. - The same prompts win every night. Candidate prompts are ranked by a deterministic score (volume, visibility gap, competitor gap), so the model is shown the same ordered list each run and the three slots keep going to the prompts at the top.
- Invalid indexes fall back to the top prompt. When the model returns an out-of-range
relatedPromptIndex, the opportunity is attached toscored[0]instead of being dropped, which adds to the most crowded prompt.
Proposed change
Apply the same rules in both generators, ideally through one shared helper so they can't drift apart. server/src/lib/opportunity-limits.js already plays this role for the per-run count.
- Cap open opportunities per prompt. Before building the prompt data, drop candidate prompts that already have
MAX_OPEN_PER_PROMPT(3) or more opportunities with statusnew. Define the constant next toOPPORTUNITIES_PER_RUN. This frees the slots for prompts that have no suggestions yet. - Show the model what it already suggested. For the remaining candidates, include their existing open titles in the prompt data and tell the model not to repeat or rephrase them.
- Drop invalid indexes. Discard any opportunity whose
relatedPromptIndexis out of range instead of falling back to the first prompt. - Keep the exact-title check as a last guard, and add it to the Generate-button path.
This change is generation-only. It needs no migration and leaves existing rows untouched.
How to test
- Add unit tests for the selection logic: prompts at the cap are excluded, prompts under the cap stay, and an out-of-range index is dropped.
opportunity-limits.test.jsshows the test style. - Manual check: for a brand whose top prompt already has 3+ open opportunities, trigger Generate. The new opportunities should land on other prompts.
Run yarn test and yarn format:check from server/ before opening the PR. See CONTRIBUTING.md for conventions.
Activity
gkhngyk commentedon Sep 30, 2026
Longer term, #857 moves opportunity generation from single prompts to clusters of related prompts, which replaces this per-prompt cap with a per-cluster one. This issue is still worth landing first: it stops the pile-up now, while #857 is a larger change.
fix(content): stop opportunities piling up on the same prompts (ansvi…