fix: prevent bot ping-pong in implicit continuation window

Exclude is_bot_message from implicit continuation trigger check.
Previously, bot A's response would trigger bot B's continuation
window, causing infinite back-and-forth responses.

Also: tool activity sub-lines use description over summary,
and max activities reduced to 2.
This commit is contained in:
Eyejoker
2026-03-23 18:44:43 +09:00
parent ac11cb7df1
commit 6268ee64ed
3 changed files with 17 additions and 18 deletions

View File

@@ -44,7 +44,9 @@ export function createImplicitContinuationTracker(idleTimeout: number) {
implicitContinuationUntil.delete(chatJid);
return false;
}
return messages.some((message) => message.is_from_me !== true);
return messages.some(
(message) => message.is_from_me !== true && !message.is_bot_message,
);
},
};
}

View File

@@ -228,11 +228,16 @@ export class MessageTurnController {
if (minutes > 0) elapsedParts.push(`${minutes}`);
elapsedParts.push(`${seconds}`);
const activityLines = this.toolActivities.length > 0
? '\n' + this.toolActivities.map((a) => `${a}`).join('\n')
: '';
const activityLines =
this.toolActivities.length > 0
? '\n' + this.toolActivities.map((a) => `${a}`).join('\n')
: '';
const suffix = `\n\n${elapsedParts.join(' ')}`;
const maxText = 2000 - TASK_STATUS_MESSAGE_PREFIX.length - activityLines.length - suffix.length;
const maxText =
2000 -
TASK_STATUS_MESSAGE_PREFIX.length -
activityLines.length -
suffix.length;
const truncated =
text.length > maxText ? text.slice(0, maxText - 1) + '…' : text;
return `${TASK_STATUS_MESSAGE_PREFIX}${truncated}${activityLines}${suffix}`;
@@ -265,16 +270,16 @@ export class MessageTurnController {
private bufferProgress(text: string): void {
if (this.pendingProgressText) {
void this.sendProgressMessage(this.pendingProgressText);
this.toolActivities = [];
}
this.pendingProgressText = text;
this.toolActivities = [];
}
/**
* Append a tool activity line and update the progress message in-place.
*/
private addToolActivity(description: string): void {
const MAX_ACTIVITIES = 5;
const MAX_ACTIVITIES = 2;
this.toolActivities.push(description);
if (this.toolActivities.length > MAX_ACTIVITIES) {
this.toolActivities = this.toolActivities.slice(-MAX_ACTIVITIES);