mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-07 22:44:16 +00:00
fix(agents): remove synthetic done fallback reply
This commit is contained in:
@@ -129,18 +129,17 @@ describe("buildEmbeddedRunPayloads", () => {
|
||||
expectSinglePayloadText(payloads, "All good");
|
||||
});
|
||||
|
||||
it("adds completion fallback when tools run successfully without final assistant text", () => {
|
||||
it("does not add synthetic completion text when tools run without final assistant text", () => {
|
||||
const payloads = buildPayloads({
|
||||
sessionKey: "agent:main:discord:direct:u123",
|
||||
toolMetas: [{ toolName: "write", meta: "/tmp/out.md" }],
|
||||
lastAssistant: makeStoppedAssistant(),
|
||||
});
|
||||
|
||||
expectSinglePayloadText(payloads, "✅ Done.");
|
||||
expect(payloads[0]?.isError).toBeUndefined();
|
||||
expect(payloads).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("does not add completion fallback for channel sessions", () => {
|
||||
it("does not add synthetic completion text for channel sessions", () => {
|
||||
const payloads = buildPayloads({
|
||||
sessionKey: "agent:main:discord:channel:c123",
|
||||
toolMetas: [{ toolName: "write", meta: "/tmp/out.md" }],
|
||||
@@ -154,7 +153,7 @@ describe("buildEmbeddedRunPayloads", () => {
|
||||
expect(payloads).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("does not add completion fallback for group sessions", () => {
|
||||
it("does not add synthetic completion text for group sessions", () => {
|
||||
const payloads = buildPayloads({
|
||||
sessionKey: "agent:main:telegram:group:g123",
|
||||
toolMetas: [{ toolName: "write", meta: "/tmp/out.md" }],
|
||||
@@ -168,7 +167,7 @@ describe("buildEmbeddedRunPayloads", () => {
|
||||
expect(payloads).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("does not add completion fallback when messaging tool already delivered output", () => {
|
||||
it("does not add synthetic completion text when messaging tool already delivered output", () => {
|
||||
const payloads = buildPayloads({
|
||||
sessionKey: "agent:main:discord:direct:u123",
|
||||
toolMetas: [{ toolName: "message_send", meta: "sent to #ops" }],
|
||||
@@ -183,7 +182,7 @@ describe("buildEmbeddedRunPayloads", () => {
|
||||
expect(payloads).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("does not add completion fallback when the run still has a tool error", () => {
|
||||
it("does not add synthetic completion text when the run still has a tool error", () => {
|
||||
const payloads = buildPayloads({
|
||||
toolMetas: [{ toolName: "browser", meta: "open https://example.com" }],
|
||||
lastToolError: { toolName: "browser", error: "url required" },
|
||||
@@ -192,7 +191,7 @@ describe("buildEmbeddedRunPayloads", () => {
|
||||
expect(payloads).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("does not add completion fallback when no tools ran", () => {
|
||||
it("does not add synthetic completion text when no tools ran", () => {
|
||||
const payloads = buildPayloads({
|
||||
lastAssistant: makeStoppedAssistant(),
|
||||
});
|
||||
|
||||
@@ -4,7 +4,6 @@ import type { ReasoningLevel, VerboseLevel } from "../../../auto-reply/thinking.
|
||||
import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../../../auto-reply/tokens.js";
|
||||
import { formatToolAggregate } from "../../../auto-reply/tool-meta.js";
|
||||
import type { OpenClawConfig } from "../../../config/config.js";
|
||||
import { deriveSessionChatType } from "../../../sessions/session-key-utils.js";
|
||||
import {
|
||||
BILLING_ERROR_USER_MESSAGE,
|
||||
formatAssistantErrorText,
|
||||
@@ -310,7 +309,7 @@ export function buildEmbeddedRunPayloads(params: {
|
||||
}
|
||||
|
||||
const hasAudioAsVoiceTag = replyItems.some((item) => item.audioAsVoice);
|
||||
const payloads = replyItems
|
||||
return replyItems
|
||||
.map((item) => ({
|
||||
text: item.text?.trim() ? item.text.trim() : undefined,
|
||||
mediaUrls: item.media?.length ? item.media : undefined,
|
||||
@@ -330,18 +329,4 @@ export function buildEmbeddedRunPayloads(params: {
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (
|
||||
payloads.length === 0 &&
|
||||
params.toolMetas.length > 0 &&
|
||||
!params.lastToolError &&
|
||||
!lastAssistantErrored &&
|
||||
!params.didSendViaMessagingTool
|
||||
) {
|
||||
const sessionChatType = deriveSessionChatType(params.sessionKey);
|
||||
if (sessionChatType === "channel" || sessionChatType === "group") {
|
||||
return [];
|
||||
}
|
||||
return [{ text: "✅ Done." }];
|
||||
}
|
||||
return payloads;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user