Skip to content

Commit 57633c4

Browse files
TurboTheTurtlevincentkoc
authored andcommitted
Fix CLI silent reply fallback policy
(cherry picked from commit 2f3762d)
1 parent cfeaf68 commit 57633c4

4 files changed

Lines changed: 49 additions & 0 deletions

File tree

src/auto-reply/reply/agent-runner-execution.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,49 @@ describe("runAgentTurnWithFallback", () => {
18731873
});
18741874
});
18751875

1876+
it("passes silent empty-reply policy to CLI backends for message-tool-only turns", async () => {
1877+
state.isCliProviderMock.mockReturnValue(true);
1878+
state.runWithModelFallbackMock.mockImplementationOnce(async (params: FallbackRunnerParams) => ({
1879+
result: await params.run("claude-cli", "claude-sonnet-4-6"),
1880+
provider: "claude-cli",
1881+
model: "claude-sonnet-4-6",
1882+
attempts: [],
1883+
}));
1884+
state.runCliAgentMock.mockResolvedValueOnce({
1885+
payloads: [{ text: SILENT_REPLY_TOKEN }],
1886+
meta: { executionTrace: { fallbackUsed: false } },
1887+
});
1888+
1889+
const runAgentTurnWithFallback = await getRunAgentTurnWithFallback();
1890+
const followupRun = createFollowupRun();
1891+
followupRun.run.provider = "claude-cli";
1892+
followupRun.run.model = "claude-sonnet-4-6";
1893+
followupRun.run.sourceReplyDeliveryMode = "message_tool_only";
1894+
followupRun.run.allowEmptyAssistantReplyAsSilent = true;
1895+
followupRun.originatingChannel = "telegram";
1896+
1897+
const result = await runAgentTurnWithFallback(
1898+
createMinimalRunAgentTurnParams({
1899+
followupRun,
1900+
sessionCtx: {
1901+
Provider: "telegram",
1902+
MessageSid: "msg",
1903+
ChatType: "group",
1904+
} as unknown as TemplateContext,
1905+
}),
1906+
);
1907+
1908+
expect(result.kind).toBe("success");
1909+
expectMockCallArgFields(state.runCliAgentMock, 0, "CLI run params", {
1910+
provider: "claude-cli",
1911+
model: "claude-sonnet-4-6",
1912+
sourceReplyDeliveryMode: "message_tool_only",
1913+
allowEmptyAssistantReplyAsSilent: true,
1914+
messageChannel: "telegram",
1915+
messageProvider: "telegram",
1916+
});
1917+
});
1918+
18761919
it("passes prepared CLI user turns to the runtime persistence boundary", async () => {
18771920
state.isCliProviderMock.mockReturnValue(true);
18781921
state.runWithModelFallbackMock.mockImplementationOnce(async (params: FallbackRunnerParams) => ({

src/auto-reply/reply/agent-runner-execution.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,6 +2198,8 @@ export async function runAgentTurnWithFallback(params: {
21982198
extraSystemPrompt: params.followupRun.run.extraSystemPrompt,
21992199
sourceReplyDeliveryMode: params.followupRun.run.sourceReplyDeliveryMode,
22002200
silentReplyPromptMode: params.followupRun.run.silentReplyPromptMode,
2201+
allowEmptyAssistantReplyAsSilent:
2202+
params.followupRun.run.allowEmptyAssistantReplyAsSilent,
22012203
extraSystemPromptStatic: params.followupRun.run.extraSystemPromptStatic,
22022204
ownerNumbers: params.followupRun.run.ownerNumbers,
22032205
cliSessionId: cliSessionBinding?.sessionId,

src/auto-reply/reply/followup-runner.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,7 @@ describe("createFollowupRunner runtime config", () => {
11191119
model: "claude-opus-4-7",
11201120
suppressNextUserMessagePersistence: true,
11211121
sourceReplyDeliveryMode: "message_tool_only",
1122+
allowEmptyAssistantReplyAsSilent: true,
11221123
},
11231124
}),
11241125
);
@@ -1129,6 +1130,8 @@ describe("createFollowupRunner runtime config", () => {
11291130
expect(call.currentInboundEventKind).toBe("room_event");
11301131
expect(call.currentInboundAudio).toBe(true);
11311132
expect(call.suppressNextUserMessagePersistence).toBe(true);
1133+
expect(call.sourceReplyDeliveryMode).toBe("message_tool_only");
1134+
expect(call.allowEmptyAssistantReplyAsSilent).toBe(true);
11321135
expect(call.cliSessionId).toBe("cli-session-1");
11331136
expect(call.cliSessionBinding).toEqual({ sessionId: "cli-session-1" });
11341137
});

src/auto-reply/reply/followup-runner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@ export function createFollowupRunner(params: {
839839
extraSystemPrompt: run.extraSystemPrompt,
840840
sourceReplyDeliveryMode: run.sourceReplyDeliveryMode,
841841
silentReplyPromptMode: run.silentReplyPromptMode,
842+
allowEmptyAssistantReplyAsSilent: run.allowEmptyAssistantReplyAsSilent,
842843
extraSystemPromptStatic: run.extraSystemPromptStatic,
843844
ownerNumbers: run.ownerNumbers,
844845
cliSessionId: cliSessionBinding?.sessionId,

0 commit comments

Comments
 (0)