Teamsbot: fix chatHistory polluting AI context, block bot self-trigger via captions
Made-with: Cursor
This commit is contained in:
parent
681c96be8e
commit
0ee86070bd
1 changed files with 4 additions and 12 deletions
|
|
@ -565,6 +565,7 @@ class TeamsbotService:
|
|||
if (
|
||||
source == "speakerHint"
|
||||
and isFinal
|
||||
and not self._isBotSpeaker(speaker)
|
||||
and self.config.responseMode != TeamsbotResponseMode.TRANSCRIBE_ONLY
|
||||
):
|
||||
shouldTriggerFromHint = self._shouldTriggerAnalysis(text, allowPeriodic=False)
|
||||
|
|
@ -587,8 +588,9 @@ class TeamsbotService:
|
|||
return
|
||||
|
||||
# Chat history: messages sent before the bot joined the meeting.
|
||||
# Stored in DB and context (available if someone refers to chat history)
|
||||
# but never used to trigger AI responses.
|
||||
# Stored in DB for reference but NOT added to the AI context buffer,
|
||||
# because old messages (e.g. "nyla, summarize the protocol") would
|
||||
# be treated as current requests when AI analysis is triggered.
|
||||
if source == "chatHistory":
|
||||
transcriptData = TeamsbotTranscript(
|
||||
sessionId=sessionId,
|
||||
|
|
@ -601,16 +603,6 @@ class TeamsbotService:
|
|||
).model_dump()
|
||||
createdTranscript = interface.createTranscript(transcriptData)
|
||||
|
||||
self._contextBuffer.append({
|
||||
"speaker": speaker or "Unknown",
|
||||
"text": text,
|
||||
"timestamp": getUtcTimestamp(),
|
||||
"source": "chatHistory",
|
||||
})
|
||||
maxSegments = self.config.contextWindowSegments
|
||||
if len(self._contextBuffer) > maxSegments:
|
||||
self._contextBuffer = self._contextBuffer[-maxSegments:]
|
||||
|
||||
await _emitSessionEvent(sessionId, "transcript", {
|
||||
"id": createdTranscript.get("id"),
|
||||
"speaker": speaker,
|
||||
|
|
|
|||
Loading…
Reference in a new issue