Skip to content

feat(chat): @mention assistant picker + chat query-rephrase fix#48

Open
rajivml wants to merge 2 commits into
feature/darwinfrom
feature/assistant-mention
Open

feat(chat): @mention assistant picker + chat query-rephrase fix#48
rajivml wants to merge 2 commits into
feature/darwinfrom
feature/assistant-mention

Conversation

@rajivml

@rajivml rajivml commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Two related chat-quality changes, branched off feature/darwin.

1. @mention assistant 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 whole
input
.

  • Trigger the 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.
  • Per-message override semantics and the visible-assistant scope are unchanged.

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, and
HISTORY_QUERY_REPHRASE told the model to "compress to mainly keywords". For
entity 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_REPHRASE now produces a standalone natural-language
    question
    (resolve references from history; do not compress to keywords).
  • search_tool passes skip_first_rephrase=True so a first/single-turn question
    is 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

  • The assistant-side role-extrapolation prompt (report TAM/CSM/Owner for the
    matched account) lives in the DB (assistant prompt), not in this PR.
  • No deploy-tag bump included — the prod image tag is bumped at deploy time
    (build-deploy), not in the feature PR.

🤖 Generated with Claude Code

rajivml and others added 2 commits June 26, 2026 17:55
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant