feat(chat): @mention assistant picker + chat query-rephrase fix#48
Open
rajivml wants to merge 2 commits into
Open
feat(chat): @mention assistant picker + chat query-rephrase fix#48rajivml wants to merge 2 commits into
rajivml wants to merge 2 commits into
Conversation
…text The chat composer already supported answering a message with a non-default assistant (alternate_assistant_id), but the "@" typeahead only fired when "@" was the first character and selecting an assistant wiped the whole input. - Trigger the assistant typeahead for an "@mention" anywhere in the message (after any whitespace), not just at the start. - On select, strip only the "@mention" token and keep the rest of the message (previously the entire input was cleared, discarding a typed question). - Match the typeahead on display name OR raw name. Extracts the mention logic into a pure, testable module (lib/assistants/mentions.ts: getMentionQuery / filterAssistantsByMention / stripMentionToken) with unit + integration tests (mentions.test.ts). Per-message override and the visible-assistant scope are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The chat flow rephrases every question (even single-turn) via history_based_query_rephrase, and HISTORY_QUERY_REPHRASE instructed the LLM to "compress to mainly keywords". For entity lookups against sources with many near-duplicate records this dropped the answer: "who is the TAM for pepsi" -> "TAM Pepsi", and since only 1 of ~50 indexed "Pepsi" account records holds the TAM/CSM fields, the bare-keyword query reranked PepsiCo, Inc. to #14 -- outside the 10 chunks fed to the LLM -- so the answer came back "TAM not available". Adding a second term ("TAM or CSM") was enough signal to pull the right record back into the window, which is why "TAM or CSM for pepsi" worked while "TAM for pepsi" did not (same pattern for every account). Verified by replay: full question -> rank #2/#3, "TAM Pepsi" -> rank #14. Slack/one-shot was unaffected (it leaves the first query verbatim). Two changes: - HISTORY_QUERY_REPHRASE now produces a STANDALONE natural-language question (resolve pronouns/references from history, but do NOT compress to keywords or drop meaningful words). Softened rephrase reranks the record #14 -> #3 (into context). Follow-up reference resolution is kept. - search_tool passes skip_first_rephrase=True so a first/single-turn question is searched verbatim (matches the Slack/one-shot flow), avoiding any rephrase round-trip when there's no history to fold in. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Two related chat-quality changes, branched off
feature/darwin.1.
@mentionassistant picker (feat)The composer already supported answering a single message with a non-default
assistant via
alternate_assistant_id, but the@typeahead only fired when@was the first character and selecting an assistant wiped the wholeinput.
@mentionanywhere in the message (after anywhitespace), not just at the start.
@mentiontoken and keep the rest of themessage (previously the entire input was cleared, discarding a typed question).
Mention logic is extracted into a pure, testable module
web/src/lib/assistants/mentions.ts(getMentionQuery/filterAssistantsByMention/stripMentionToken).2. Chat query-rephrase fix (
fix)The chat flow rephrased every question via
history_based_query_rephrase, andHISTORY_QUERY_REPHRASEtold the model to "compress to mainly keywords". Forentity lookups against sources with many near-duplicate records this dropped the
answer (e.g. "who is the TAM for pepsi" → "TAM Pepsi" ranked the only populated
account record out of the context window).
HISTORY_QUERY_REPHRASEnow produces a standalone natural-languagequestion (resolve references from history; do not compress to keywords).
search_toolpassesskip_first_rephrase=Trueso a first/single-turn questionis searched verbatim (matches the Slack/one-shot flow).
Tests
web/src/lib/assistants/mentions.test.ts— 20 unit + integration tests(trigger conditions, name/display-name filtering, token stripping, full
typeahead flow). Full web suite: 31 passing.
tsc+ ESLint clean.Notes
matched account) lives in the DB (assistant prompt), not in this PR.
(build-deploy), not in the feature PR.
🤖 Generated with Claude Code