Skip to content

Chat works out what a person is asking and answers that question first - #791

Merged
nambok merged 4 commits into
mainfrom
chat-understands-the-question
Nov 22, 2026
Merged

nambok merged 4 commits into
mainfrom
chat-understands-the-question

Conversation

@nambok

@nambok nambok commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Chat now works out what a person is asking before it answers, answers that question first, and makes no claim about connections, counts or state that a check in the same answer doesn't support.

A first question such as "what could be useful to me" got a "what's waiting on you" list, in the fixed shape that list's lookup imposed on every answer, with a claim that Jira wasn't connected. A question with a pull request comment link got the canned "found nothing" line. The causes were in code, not in one prompt line:

  • The prompt sent any "what should I work on" style question to work_needs_me and told the model to answer "in the shape its result gives" (brain.rs CHAT_SYSTEM, line 1326). There was no step to work out what was asked, and no guidance for an orientation, a correction or small talk.
  • The list's lookup appended "Write the answer in exactly this shape" to every result, whatever the question (chat_work_needs.rs:1174, :1252). The must-look nudge repeated it (chat_agent.rs:138).
  • Any answer that cited nothing was replaced by the same "found nothing" sentence (common/src/knowledge/answer.rs:242). That covered greetings, questions about Coderhelm itself, and judgements whose evidence wasn't looked up.
  • No lookup said what Coderhelm is set up to do for a team, so an orientation had nothing real to stand on, and a claim about a connection had nothing to be checked against.
  • A pull request link wasn't read as a pull request (chat_hints.rs:21), so a question about a PR comment never reached the PR.
  • The earlier answer went back to the model as plain history. Nothing named what the person was correcting or required a new check, so the follow-up repeated the claim.

Changes

  • common::chat_intent: reads the question and the last answer. It works out the intent (orientation, capability, what needs me, status, how-to, lookup, judgement, correction, small talk), the role the person says they hold, and, for a correction, the sentences of the last answer they question. It decides only what code used to force on every answer: the fixed list shape (only for "what needs me"), whether an uncited reply may stand (only small talk), and how the answer is sized. The model gets the reading as a note it checks against the question.
  • chat_understand: one place where production (brain::answer) and the evals prepare a question. It orders the tools, writes the notes, and decides where the answer must look. An orientation must call coderhelm_setup. A correction must check the disputed point again: the setup when it is about a connection, any lookup otherwise.
  • coderhelm_setup (chat_setup): what Coderhelm is set up to do for the team, checked when it is called. It covers GitHub (installation and token), Jira (the shared common::jira_connection test from Chat never says Jira isn't connected when it is; the Jira app's links heal themselves #786), connected apps and sign-ins, repositories, knowledge bases, the last 30 days of runs counted by outcome (chat_work_runs::tally), and reviews, findings, alerts and quarantined tests counted as the asker may see them. It also covers what Chat can read and what it can't do, plus what Coderhelm does, each item with a question to ask. A failed check is named as that check, never as "not connected". The lookup is read-only and registered with the permission gate.
  • chat_work_needs::render_for / NOT_THE_LIST: the list keeps its shape only for its own question. For any other question, the result says to use only the items that answer it.
  • chat_agent: an answer that cites nothing looks once with its tools (cite_something) before the no-source line replaces it. finalize_reply keeps an uncited reply only for small talk. The must-look note no longer forces the list's shape.
  • chat_hints: a GitHub pull request link gives its number, repository and whether it points at a comment. The note says comments themselves aren't readable, so the answer judges the claim from the PR's checks and runs.
  • CHAT_SYSTEM: new "Understand the question first" and "Check before you claim" sections cover intent, role, answering first, sizing, orientations, corrections and failed checks. The "what needs me" rule now applies only when that is the question.
  • Evals: chat_eval_replay and chat_eval_cases.json hold 49 cases. 8 are modelled on real question shapes, written for the made-up marina team. 41 are variants covering every intent; every intent has at least 4 cases. Each case runs through the real loop and is prepared as production prepares it. A model judge grades it once against a five-point rubric. Offline tests replay the incident with a scripted model.
  • Incident case cu_chat_answers_the_question, with its page.

Verification

Replay eval on Bedrock (claude-sonnet-5-5 answers and judges), 49 cases, main and branch run one after the other with the same cases, fixture and judge. Two full runs; every case was judged on both sides in both.

Measure main, run 1 branch, run 1 main, run 2 branch, run 2
understood 34/49 (69%) 48/49 (98%) 35/49 (71%) 48/49 (98%)
answered first 33/49 (67%) 42/49 (86%) 32/49 (65%) 42/49 (86%)
claims checked 13/49 (27%) 24/49 (49%) 12/49 (24%) 27/49 (55%)
length right 31/49 (63%) 33/49 (67%) 31/49 (63%) 31/49 (63%)
tone right 33/49 (67%) 47/49 (96%) 35/49 (71%) 47/49 (96%)
all five 7/49 (14%) 13/49 (27%) 8/49 (16%) 14/49 (29%)
all five, modelled cases 1/8 3/8 1/8 3/8

Still weak on the branch: claims checked (about half the answers state something the judge can't find in what Chat read, most often what Chat itself can or can't do), length on orientation questions, and the four "what needs me" cases (0 of 4 on both sides). Those are the next change, not this one.

Run it with CHAT_EVAL_BEDROCK=1 and AWS credentials (or CHAT_EVAL_API_KEY):

CHAT_EVAL_BEDROCK=1 CHAT_EVAL_OUT=replay.jsonl cargo test -p gateway live_replay_eval -- --ignored --nocapture

Gates, run locally as CI runs them:

Gate Result
cargo fmt --check --all clean
rustfmt --check --edition 2021 worker/src/passes/incidents/*.rs clean
cargo clippy --workspace --all-targets -- -D warnings clean
cargo test --workspace --no-fail-fast common 2896 passed (and 2 + 3 in its integration tests), gateway 1164 passed (after merging main), worker 2333 passed, 0 failed

The new tests: chat_intent (6), chat_understand (5), chat_setup (3), chat_eval_replay (6 offline: every case reads as its intent, the incident replayed with a scripted model before and after, a correction checks again, small talk stands, an uncited answer looks once, the judge's input), chat_work_runs tally, chat_hints pull request links, finalize_reply, and the incident case cu_chat_answers_the_question (3).

A newcomer who asked what could be useful to someone in his role got the
"what's waiting on you" list, in the fixed shape that list's lookup put on
every answer, with an unchecked claim that Jira wasn't connected. A
question that linked a pull request comment got the canned "found
nothing" line, because every uncited answer was replaced by it.

- common::chat_intent reads the question with the last answer: the
  intent (orientation, capability, what needs me, status, how-to,
  lookup, judgement, correction, small talk), the role the person says
  they hold, and what a correction disputes. It decides only what code
  used to force on every answer.
- chat_understand prepares a question the same way in production and in
  the evals: tool order, notes, and where the answer must look (an
  orientation looks the setup up; a correction checks the disputed
  point again).
- coderhelm_setup: what Coderhelm is set up to do for the team, checked
  when called (GitHub, Jira through common::jira_connection, connected
  apps, repositories, knowledge bases, 30 days of runs, records), plus
  what Coderhelm does. A failed check is named as that check.
- The "what needs me" list keeps its shape only for that question; an
  uncited answer looks once with its tools; small talk may go uncited;
  a pull request link is read as the pull request.
- The prompt gains "Understand the question first" and "Check before you
  claim".
- Replay evals (49 cases: 8 from real conversations, made anonymous, and
  variants of every intent) graded by a model judge; incident case
  cu_chat_answers_the_question.
…asked again instead of failing the answer

CHAT_EVAL_BEDROCK=1 runs the replay with the shell's AWS credentials, the way a hosted install calls Claude. The judge gets room for its whole verdict and the full text of what Chat read, and a case it never graded is marked as not judged rather than counted as a failure.
@nambok
nambok merged commit 3d30014 into main Nov 22, 2026
10 checks passed
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