Repository navigation
fix(cloro): read names instead of ChatGPT entity tags in answers - #1097
Merged
Merged
Conversation
ChatGPT answers from Cloro can carry tags such as <Entity category="software" value="Tesseract" disambig="..."/> where the name should be. They showed as literal text on the answer, and their attributes counted as mentions: a competitor named only in disambig was counted, and the extra names shifted mention positions. - Clean the tags to their value when a Cloro result is parsed, so new answers are stored clean. - Match names on tag-free text in the response parser, so recounting stored answers gives the right numbers. - Clean stored answers when they are shown and in report excerpts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk
approved these changes
Oct 16, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Thanks, approving. Merged onto main with #1098, #1091, #1092 and #1087, server tests pass (1278) and web tests pass (832). On production 612 of the last 30 days' 46,351 ChatGPT answers carry the tags (since Oct 9), plus 83 ChatGPT Shopping answers; no other engine has any. Their stored mention counts and positions still need the recount you mention, as a separate PR.
4 of 12 tasks
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.
Summary
ChatGPT answers from Cloro (
chatgpt-web) can contain entity tags where a name should be, for example<Entity category="software" value="Tesseract" disambig="Adlift AI search optimization platform"/>. This was seen on app.ansvisor.com on 2026-10-16, on the prompt "What is the most comprehensive list of software for AI search engine optimization?" (ChatGPT run of Oct 16, 05:15 GMT+3).response-parser.jsmatched names inside the tag attributes:disambigwas counted as mentioned.category="software".mention_positionandmentioned_entity_count. In one sample answer the brand ranked 4th instead of 2nd.Changes:
server/src/lib/entity-markup.js(stripEntityMarkup) replaces each self-closing<Entity … value="X" …/>withX, unescaping XML escapes in the value. A tag without avalueis left as is.parseScraperResponseapplies it to every engine's text, so new answers are stored clean. Sentiment, reports, improve evidence and opportunity generation then all read the names.matchableText). Recounting stored answers therefore gives the right numbers too.web/src/lib/entity-markup.tsmirrors the helper. It is used byResponseDetail(prompt page run rows and the result page) and by the report mention excerpt, so answers stored before this fix also read properly.Existing production rows are not rewritten here. They display correctly through the web change, but their stored mention counts and positions still come from the raw text. A backfill to recount them (and clean
response) would be a separate PR.Related issue
None. The problem was seen in production on 2026-10-16.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd server && npm test:entity-markup.test.js, plus the new cases inresponse-parser.test.js(disambig/category attributes are not counted, ranks follow the visible names) andcloro-scraper.test.js(stored text is clean).cd web && yarn test:src/lib/entity-markup.test.ts.chatgpt-webprompt_resultsrow for a demo prompt whoseresponsecontains tags, e.g.**<Entity category="company" value="Acme Coffee" disambig="specialty coffee roaster"/>** — …./dashboard/prompts/<id>), expand the ChatGPT group and open that run's response. Then open its full page (/dashboard/insights/<result id>). Both should show "Acme Coffee", not the tag. Onmainthe tag shows as literal text.Checked locally in light and dark themes and at 1024px.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Also run:
web:yarn test(726 tests) andyarn build.server:npm run format,npm run lintandnpm test(1204 tests).npm run version:checkfails, but it fails onmaintoo (docker-compose images 0.2.0 vs 0.3.0) and is unrelated to this change.🤖 Generated with Claude Code