Repository navigation
fix(chat): look up any listed item by its code, id, words or address - #2460
Merged
Merged
Conversation
…report by what the person names
Chat answered "what is X?" from the first page of a list, so an item past it
read as missing. Each list read now takes a direct lookup:
- list_signals: codes ("S-07", "S 7", "s7", "#7", "7") and ids, every status and date
- list_prompts: search (words of the text, any order and case) and ids, every topic and state
- get_prompt_performance: prompt_ids, whatever the topic; tracked prompts with no answers in no_results
- list_citations: domains (with subdomains, top pages and citing prompts) and urls (scheme, www and trailing slash aside), every source type
- list_content_opportunities, list_drafts, get_reports: search (title words) and ids, archived included
Each returns what it found and not_found, with a note to say "not found"
plainly and never offer the closest. A lookup is never cut by limit
(NAMED_ROWS). Every read keeps brandAllowed, the brand_id filter and the
organization join; words reach the filter only as escaped ilike patterns.
Shared helpers in lib/mcp/lookup.ts; MCP tool shapes unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
gkhngyk
approved these changes
Nov 16, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Minor: with ids and a search in one call, scope.ts (~447) caps rows at 50 while lookUpBy returns up to 10 id rows + a 50-row search page, so the search's next_offset skips the rows cut; list_citations domain rows can also exceed the cap with no way to page.
gkhngyk
pushed a commit
that referenced
this pull request
Nov 16, 2026
…eport by what the person names An MCP client asked "what is S-07?", "how does the 'skip a month' prompt do?" or "is example.com cited?" could only page a list (50 signals, 100 prompts, the top 50 domains, ...), so an item past the page looked missing and the client could answer with the closest ones instead. Chat got direct lookups in #2460; the MCP tools now read them the same way, through Chat's reads: the same query, rows and note, no second query. - list_signals: `codes` ("S-07", "S 7", "s7", "#7", "7") and `ids`, every status and date (lookUpSignalsFor). status, kind and limit don't apply. - list_prompts: `search` (words of the text, any order and case) and `ids`, every topic and state (lookUpPromptsFor). topic_id, is_active and limit don't apply. - get_prompt_performance: `prompt_ids`, whatever the topic, never cut by limit; tracked prompts with no answers in no_results (lookUpPromptPerformanceFor). topic_id, sort_by, order and limit don't apply. - list_citations: `domains` (with subdomains, top pages and citing prompts) and `urls` (scheme, www and trailing slash aside), every source type (lookUpCitationsFor). source_filter and limit don't apply. - list_content_opportunities, list_content_drafts, list_reports: `search` (title words) and `ids`, archived included where the list has it (lookUpOpportunitiesFor, lookUpDraftsFor, lookUpReportsFor). Their filters and limit don't apply. - A search pages 50 at a time: `offset` on those four tools takes the result's next_offset and applies to a search only. - Each returns { note, <rows>, not_found } in place of the list. Without a lookup input every tool reads exactly as before. - Scope as before: brandAllowed (organization and brand access), the brand_id filter and an inner join on the brand's organization. An id or code of another brand or workspace is not found; ids are checked as UUIDs, codes become numbers, words reach a filter only as escaped ilike patterns (#2460). - Descriptions: read what the person names first; which list inputs a lookup ignores; "not found" plainly, never the closest; never say an item doesn't exist because a page didn't show it. get_report, get_content_draft and get_content_opportunity say where a named one's id comes from. - The REST mirrors (/api/mcp/*) are unchanged. - Docs: the MCP guide's rows. Help: one example line in the MCP article's "What you can ask". The coach skill names the new inputs where it lists each tool's inputs, and a pitfall for "missing because a list didn't show it". Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
cihan-gyk
pushed a commit
to cihan-gyk/ansvisor
that referenced
this pull request
Nov 16, 2026
The page's search (from its view) now fills `search` on the reads of the page's own list that take one, as ansvisor#2459 fills its list filters: as ansvisor#2460's capped lookup words, never over the model's own search, ids or codes, not for another brand's page, and dropped when the question asks for all. The read's scope names it (from_page.search) and the writer says it. In the models' page_view block every row and ref stay, each label cut to 80 characters; the stored view's cap is now a safety net that every 100-row view fits under. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
cihan-gyk
pushed a commit
to cihan-gyk/ansvisor
that referenced
this pull request
Nov 16, 2026
Brings in ansvisor#2449, ansvisor#2450, ansvisor#2457, ansvisor#2460 and ansvisor#2461 (Chat and MCP lookups by code, id, words, domain or address; never give up on data it could read). Conflicts, resolved as the union of both sides: - agent-eval.ts: the scenario keeps askedSignals/askedDomains and checks; QUESTION_SCENARIOS holds action-by-code, signal-by-code, citation-by-domain and the three ai-revenue questions; every run gets "never gives up on data it could read" and then its scenario's checks. - agent-eval-data.ts: EvalWorkspace is default, action_backlog, long_lists and conversions_off; both sides' imports. - agent-eval.test.ts: both sides' imports. - brand-scope.test.ts: the AI-revenue reads and the lookups. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
This was referenced Nov 16, 2026
gkhngyk
pushed a commit
that referenced
this pull request
Nov 18, 2026
Stacks step 7 on both open Chat PRs (#2459 page period and filters, #2460 lookups by name). Their eval scenarios, eval data, eval tests and Chat help keywords are kept as a union; approved-articles.json is regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
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
Step 2 of the owner's plan "Chat must read everything a page shows" (16 Nov): lookups for every visible code or name.
not_foundfor what it didn't. A shortnotetells Chat to say "not found" plainly, with where it looked, and never to offer "the closest" items.codesonlist_action_center_tasks).Changes
list_signalscodes,idssearchedSignalNo, the same rule as the Signals search), or its id. Every status and date: the period, status, kind and page don't apply.list_promptssearch,idssearchsomewhere in the prompt's text, in any order and case, or the id. Every topic, active and paused:topic_idandis_activedon't apply. Search results page byoffset.get_prompt_performanceprompt_idstopic_id, sort, order and the page don't apply. A tracked prompt with no answers in the window goes inno_results.list_citationsdomains,urlswww.and path don't matter) finds itself and its subdomains, each with its 5 most cited pages. An address finds its page however it is written: scheme,www., query and a trailing slash don't matter. Each item comes with the prompts whose answers cite it. Every source type:source_filterand the page don't apply. Not cited in the period: it goes innot_found, and for a page the note also says whether its domain is cited.list_content_opportunitiessearch,idslist_draftssearch,idsarchived: true.get_reportssearch,idsNAMED_ROWSinscope.tsnow lists the fields of each lookup above. If the model sends alimitbeside a lookup, it is dropped. This is a small, local change: a field list and anamesRows()helper.list_signalspage rows now carrycode(S-07). The actions built on a signal now show the codes the app shows (AC-03). Before, they showed the old global number (AC-1497).get_draft's id input now points tolist_drafts' search.lib/mcp/lookup.ts. The reads and the eval both use it. The DB lookups arelookUpSignalsFor(signal-page.ts);lookUpPromptsFor,lookUpPromptPerformanceFor,lookUpCitationsFor,lookUpOpportunitiesForandlookUpReportsFor(data.ts); andlookUpDraftsFor(content.ts).promptsPageFor,contentOpportunitiesPageForandgetPromptPerformanceForget new optional params, andreportsPageForandcontentDraftsPageForget a new optional last argument.listCitationsFor's scan moved intoreadCitationAggregates, which both citation reads share. Its output is unchanged.READ_ON_RULESandNEVER_GIVE_UP_RULESalready say to look an item up first.rules.tsandengine.tsaren't touched.approved-articles.jsonwas regenerated.long_listsworkspace:signal-by-code: "S-07 nedir". S-07 is resolved, from August, and past the first page of 60 signals.citation-by-domain: "decafdigest.example yapay zekâ yanıtlarında kaç kez kaynak gösterildi?". The domain is 66th of 70.give-up.tscountsdomains,urlsandprompt_idsas lookups.Safety
brandAllowedfirst: the run's organization and the person's brand access. Nothing else is read for a brand outside them.brand_id.brands.organization_id. Prompts joinprompt_sets.brands.organization_id.not_found.brand-scope.test.tscover all 7 lookups..ilike()as%word%, with\,%and_escaped.*is dropped, because PostgREST reads it as a wildcard.or()with text.list_citations, which stays an untrusted read, as before.How to test
www.and a trailing slash: "https://example.com/blog/x/ sayfası kaynak gösterildi mi?". Then ask about a page that isn't cited.cd web && SKILL_EVAL=signal-by-code,citation-by-domain yarn vitest run src/lib/chat/agent-eval.test.tsChecks
npx tsc --noEmit -p .: passes.src/lib/chat,src/lib/mcp,src/lib/action-center,src/lib/signals,src/components/chat,src/lib/help,src/i18n,use-server-exportsandsubscription-guard-coverage: 344 files, 4,971 tests pass (1 skipped).src/app/api/mcp,src/app/api/chat,src/lib/actions), with 457 tests.lib/mcp/lookups.test.ts, 31 tests on the fake Supabase: every form of a code; ids in any case; words in any order and case;%and_read as text, and*never sent; domain against URL normalization; an ambiguous code returning both signals; a match past the first page found; a search paging past 50;not_foundand its note; another brand or workspace never read; a brand that isn't shared reading nothing but the brand.scope.test.ts:limitnever cuts any lookup.signal-by-codepasses a good answer and fails a "closest" one;citation-by-domainpasses.git merge-treewithmainis clean. fix(chat): read over the page's dates and filters in the side panel #2459 (the page's dates and filters) also editsscope.ts; whichever lands second getsmainmerged in.signals_brand_no_key(from 00534's runbook) when it is built. Until then, the existing(brand_id, detected_at)index keeps the lookup to one brand's signals.Not in this PR:
get_report).scopeRead(), which fix(chat): read over the page's dates and filters in the side panel #2459 changes.Follow-ups for the owner to decide (this PR doesn't depend on them)
list_signals,list_prompts,get_prompt_performance,list_citations,list_content_opportunities,list_content_drafts,list_reports) could take the same lookup inputs, as fix(mcp): look up an action by its code, and never answer with "the closest" ones #2452 did for actions. The shared functions are ready. This PR keeps them Chat-only.Generated by Claude Code