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 (
|
if (
|
||||||
source == "speakerHint"
|
source == "speakerHint"
|
||||||
and isFinal
|
and isFinal
|
||||||
|
and not self._isBotSpeaker(speaker)
|
||||||
and self.config.responseMode != TeamsbotResponseMode.TRANSCRIBE_ONLY
|
and self.config.responseMode != TeamsbotResponseMode.TRANSCRIBE_ONLY
|
||||||
):
|
):
|
||||||
shouldTriggerFromHint = self._shouldTriggerAnalysis(text, allowPeriodic=False)
|
shouldTriggerFromHint = self._shouldTriggerAnalysis(text, allowPeriodic=False)
|
||||||
|
|
@ -587,8 +588,9 @@ class TeamsbotService:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Chat history: messages sent before the bot joined the meeting.
|
# Chat history: messages sent before the bot joined the meeting.
|
||||||
# Stored in DB and context (available if someone refers to chat history)
|
# Stored in DB for reference but NOT added to the AI context buffer,
|
||||||
# but never used to trigger AI responses.
|
# because old messages (e.g. "nyla, summarize the protocol") would
|
||||||
|
# be treated as current requests when AI analysis is triggered.
|
||||||
if source == "chatHistory":
|
if source == "chatHistory":
|
||||||
transcriptData = TeamsbotTranscript(
|
transcriptData = TeamsbotTranscript(
|
||||||
sessionId=sessionId,
|
sessionId=sessionId,
|
||||||
|
|
@ -601,16 +603,6 @@ class TeamsbotService:
|
||||||
).model_dump()
|
).model_dump()
|
||||||
createdTranscript = interface.createTranscript(transcriptData)
|
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", {
|
await _emitSessionEvent(sessionId, "transcript", {
|
||||||
"id": createdTranscript.get("id"),
|
"id": createdTranscript.get("id"),
|
||||||
"speaker": speaker,
|
"speaker": speaker,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue