Repository navigation
feat(tracking): keep the searches the OpenAI API model ran as its query fan-out - #1756
Merged
Merged
Conversation
… Cloro's legacy interface ChatGPT's default (mobile-web) interface has carried no query text since 2026-09-30, so its tasks stopped asking for fan-out (ansvisor#1119). Cloro's legacy desktop interface (`legacy: true`) still returns `searchQueries`, at the add-on's +2 credits a task. - CLORO_CHATGPT_FANOUT = off | sample | all (default sample). On sample a prompt's ChatGPT task asks one UTC weekday a week, picked from a hash of the prompt id (no stored state, spread across the week). That day's answer is the tracked one; no extra request. - The tracking worker decides per task and passes `legacy` to submitScraperTask / buildRequestBody, which stays pure. A legacy task Cloro refuses is submitted again without it. - Health report: on sample, ChatGPT is judged over the last 7 days (flagged when none of its answers carried fan-out) instead of day against days before, which swings by design; on all it is expected daily; on off it is not judged. - Docs: env var in self-host docs and .env.example; Prompts guide explains the weekly sample. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nightly runs Review follow-ups for the sampled ChatGPT fan-out. - A legacy ChatGPT task that Cloro takes and then fails goes once more without legacy, in both paths: the webhook reads it from the new cloro_pending_tasks.legacy column (00378) and swaps in the new task's pending row; polling uses the submission's own record. - A refused submission is sent again without legacy only on 400/422. submitScraperTask errors now carry the HTTP status; a network error, timeout, 429, 5xx, 401 or 402 is never resubmitted, since the first task may exist and be billed. - Only the nightly run's first attempt asks (source 'cron', attempt 1): manual runs, analyze-new, retries and recovered runs don't. - CLORO_CHATGPT_FANOUT unset: sample on the cloud, off on self-host. An unknown value is off and logged once. - Health report: sampled ChatGPT needs 7 x FANOUT_MIN_ANSWERS answers before a silent week or a silent day is flagged; if the extra days can't be read, only ChatGPT goes unjudged. - Web: ChatGPT is neither "shares" nor "not shared" on the Query Fan-out page, and its copy says ChatGPT's searches are sampled on some days. - Docs: per-location cost, nightly-only, and the UTC-midnight caveat; the probe notes the legacy sources/footnote check still to run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ry fan-out
ChatGPT's fan-out has come only once a week through Cloro since
2026-09-30. The OpenAI API model's answers carry theirs already: the
Responses web_search calls hold the queries they ran. They were dropped.
- openai-tracker.js: searchQueriesOf reads each web_search_call's search
action (`query`, and `queries` when given; open_page and find_in_page
aren't searches) into the fan-out shape [{ query, source_platform:
'chatgpt' }], trimmed and once each. From the same response: no other
call, no extra cost.
- tracking-worker.js: the model path's insertResult keeps search_queries,
as the scraper path does (Claude's gives none: an empty list).
- The Query Fan-out page counts `chatgpt` (the API model) among the
engines that share their searches (fanout-platforms.ts), and the daily
health report expects it (FANOUT_EXPECTED), its warning pointing at
OpenAI rather than Cloro.
On Cloud, API-model tracking is off on every plan (allowedModels []), so
this shows where an OpenAI model is tracked: self-host, or an Enterprise
plan_overrides. ChatGPT's own interface (chatgpt-web) is unchanged here.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-ups for the API model's query fan-out. - Health report: `chatgpt` leaves FANOUT_EXPECTED. gpt-5-chat-latest may run web_search rarely or not at all, so a silent day is no news; a fall from the days before still is, and points at OpenAI. - Web: `chatgpt` is neither "shares" nor "not shared" on the Query Fan-out page; fanout-platforms.test.ts checks fanoutSharing's answers rather than the lists. - searchQueriesOf reads the action's `queries` first (`query` is deprecated) and skips web_search calls whose status is `failed`. - Copy: the Prompts guide calls it "ChatGPT API" as the page does and says Claude and Gemini models' searches aren't captured yet; the empty state and coverage tooltip mention the API model. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
…out-legacy # Conflicts: # server/src/lib/cloro-scraper.js # server/src/workers/tracking-worker.js # supabase/schema.sql
Collaborator
Author
gkhngyk
approved these changes
Oct 29, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good.
What I checked (this PR's own diff against #1755)
- No extra provider cost.
searchQueriesOfreads theweb_search_callitems of the responserunPromptalready gets. There is no second call and no extrainclude. Claude and Gemini return nosearch_queries, so the worker writes[], the column's default. - Parsing.
- Only
action.type === 'search'counts.open_page/find_in_pageandstatus: 'failed'calls are skipped. queries[]and the deprecatedqueryare both read. Queries are trimmed, and empty ones and duplicates within an answer are dropped.- Non-string values are ignored. The loop is linear in the output items.
- Only
- Shape.
{ query, source_platform: 'chatgpt' }is the platform API-model results are stored under, so the fan-out reads (and the web's "ChatGPT API" label) line up with the result row. - Health report.
chatgptis judged on a drop only, not on missing fan-out every day. That's right for a model that may not search. - No migration, no PostgREST embeds, no new routes or server actions.
- Tests:
openai-tracker(including the single-callrunPromptcase),reportand the webfanout-platformstests pass on this branch.
Merge on main: this branch contains #1755, so it has #1755's conflicts in server/src/lib/cloro-scraper.js and server/src/workers/tracking-worker.js with #1730. See my note there: submitPromptTask needs googleLocationFor(region). This PR's own lines (the model path's insertResult) don't conflict.
Follow-up
- On the cloud no plan allows API models today, so this only shows on self-hosted installs and Enterprise workspaces with
plan_overrides. The PR already asks for one real answer fromgpt-5-chat-latestto confirm it returnsaction.queries.
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
The OpenAI API model (platform
chatgpt, set per prompt, defaultgpt-5-chat-latest) already runs OpenAI'sweb_searchtool, but the searches it ran were thrown away. This keeps them as the answer's query fan-out, read from the same response, with no extra call or cost.What changes
openai-tracker.js: a newsearchQueriesOf(output)reads eachweb_search_callwhoseaction.typeissearch.action.queries[](the current field) andaction.query(deprecated), trims them, drops empty ones, and keeps each query once per answer.open_pageandfind_in_pagearen't searches, and afailedsearch is skipped.runPromptreturns them assearch_queries: [{ query, source_platform: 'chatgpt' }], the same shape Cloro's engines write.tracking-worker.js: the model path'sinsertResultnow passessearch_queries(it already did on the scraper path). Claude and Gemini models return none, so they write[](the column's default).chatgptis judged on a drop only, not expected every day. A model may run few or no searches, so "none today" isn't an outage on its own. The warning points to OpenAI'sweb_search, not Cloro.chatgptstays neutral (unknown) on the Query Fan-out page, so an API model that searched rarely isn't flagged as "shares its searches, but none arrived". Its searches show under ChatGPT API. Theen.jsonlines describe the API models too.prompts.mdxadds a short "API models' fan-out" section. Claude and Gemini read "we don't capture them yet".Scope: on the cloud no plan allows API models today (
allowedModels: []). So this shows where an OpenAI model is tracked: self-hosted installs and Enterprise workspaces opened up withplan_overrides.Related issue
Follows #1119.
Stacked on #1755 (ChatGPT fan-out sampled through Cloro's legacy interface). The diff against it holds only this change.
Type of change
feat— New featureHow to test
openai-tracker.test.js:queries,query,open_page,find_in_page, a failed search, duplicates, andrunPromptmaking one call that returnssearch_queries.report.test.js:chatgptis judged on a drop only.fanout-platforms.test.ts:fanoutSharingbehaviour.OPENAI_API_KEY: track a prompt with an OpenAI model. After a run, Prompts › Query Fan-out lists its searches under ChatGPT API.For the maintainer (needs an OpenAI key): one real answer from the default
gpt-5-chat-latest, to confirm it returnsweb_search_callitems withaction.queries.Checklist
Checks on this branch (fc6d27a): server 281 test files / 3,948 tests (3 skipped); web lint 0 errors (7 warnings), typecheck, build OK; web tests 555 of 556 files:
_before-publish.test.tsxfailed on the known focus race that #1753 fixes (untouched here).🤖 Generated with Claude Code