Repository navigation
Answer only the tagged message and mark speaker changes - #46
Merged
Merged
Conversation
The channel chatter (the recent window, or the gap since the last turn) rides in the same user message as the question, and nothing told the model it was background: the conversation block even said to answer "the last user message", which contains all of it. So the bot answered the channel's other topics along with what it was asked. - The system prompt (chat and /ask, so Spark too) now explains how a turn reads: what comes before the [Por …] tag is prepared for the bot, and it answers only what that person wrote; channel messages are there to understand the question, not to answer, comment on or summarize; when the person changes topic, follow the new one. - The recent window and the gap header say they are only context. The burst rule now says the lines are the ones under the tag. Every speaker is the `user` role, so a change of speaker was only visible in the name inside the tag, and the participant list left out whoever was speaking for the first time. - The tag says "outra pessoa — antes falava …" when the speaker differs from the previous turn's. It is written when the turn is captured, so verbatim replay stays byte-identical; compact turns get the same mark (it replaces "nova pessoa na conversa"). - The conversation block lists participants "até agora" and says who is speaking now: the author of the last message's tag, who may be new. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
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.
Problem
The bot answered more than it was asked, and lost track of who was talking. Example: the channel talks about topic Y with the bot, then moves on to topic X, then someone @mentions the bot to search something about X. The answer covers X and also brings Y back.
I replayed that scenario through the real
ChatEngineandrun_turn, with a fake LLM that only records the request. The search request looked like this:Two problems in how the request is built:
<mensagens_recentes_do_canal>isn't explained at all. The burst rule "responda a todas de uma vez" also fits the chatter, which is one message per line too.userrole, so the only sign of a new speaker is the name in the tag. The compact rendering marked it ("nova pessoa na conversa"), but verbatim replay (the last 6 turns) didn't. The participant list in<conversa_em_andamento>also leaves out anyone speaking for the first time (John above).Changes
The chatter is background, and the bot answers only the tagged message
core/prompts.py: newCONTEXT_INSTRUCTIONSat the top of the chat and/askinstructions (so Spark gets it too). Everything before the[Por …]tag is prepared for the bot. It answers only what that person wrote. A replied-to message shows up under the tag as[Mensagem respondida — …]. Channel messages are for understanding the question, not to be answered, commented on or summarized unless asked. When the person changes topic, the bot follows the new one.<canal>and<memory>are described as "prepared for you", not "ignore", so channel instructions are still followed.core/context.pyandcore/conversations.py: the recent window opens with "(… — só contexto: não são pedidos para você.)". The gap header gets the same note:[Mensagens no canal antes desta pergunta (channel_id=…) — só contexto: …].Speaker changes
core/conversations.py: newspeaker_change().author_tag()/build_current_message()take the previous turn's author and addoutra pessoa — antes falava Ana (@ana)to the tag when it differs.run_turnpassesctx.history[-1]['author'].<conversa_em_andamento>now says "Participantes até agora". It explains the mark and says who is speaking now: the author of the last message's tag, who may not have spoken before.Not in this PR
CHAT_MENTION_CONTINUE_WINDOWmessages of a live answer to that conversation, from anyone and about anything. That's how John's question got Ana's conversation in the example. The model is now told someone else took over and to follow the current topic, but the old history is still replayed. Limiting the merge to the same person would be a separate change.[Mensagem respondida — …]quote still has noauthor_id.Prompt cache
The system prompt changes, and so does the gap header in the compact rendering of older turns. That causes one prefix-cache miss per conversation after deploy. Turns stored before this keep their captured text, without the mark, and are still replayed byte-identically.
Tests
tests/test_attribution.py: the mark in the tag, and none for the same speaker, a missing previous author or one without an id. The mark survives verbatim replay unchanged and the compact rendering marks the same turns. The conversation block lists participants so far and names the current speaker.tests/test_context_framing.py: the instructions are in the chat,/askand Spark prompts. The gap block and the recent window are labelled as context. A realrun_turnrequest marks a new speaker and doesn't mark the same one.ruff check .is clean.🤖 Generated with Claude Code