Skip to content

Commit 42fccfb

Browse files
committed
fix(replies): suppress terminal verbose tool warnings
1 parent acc513b commit 42fccfb

2 files changed

Lines changed: 72 additions & 0 deletions

File tree

src/auto-reply/reply/dispatch-from-config.test.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,6 +2063,68 @@ describe("dispatchReplyFromConfig", () => {
20632063
expect(dispatcher.sendFinalReply).not.toHaveBeenCalled();
20642064
});
20652065

2066+
it("suppresses terminal tool-error fallbacks when regular verbose progress is visible", async () => {
2067+
setNoAbort();
2068+
sessionStoreMocks.currentEntry = {
2069+
sessionId: "s1",
2070+
updatedAt: 0,
2071+
sendPolicy: "allow",
2072+
verboseLevel: "on",
2073+
};
2074+
const dispatcher = createDispatcher();
2075+
const ctx = buildTestCtx({
2076+
Provider: "telegram",
2077+
ChatType: "direct",
2078+
SessionKey: "agent:main:telegram:direct:U1",
2079+
});
2080+
let receivedOptions: GetReplyOptions | undefined;
2081+
const replyResolver = vi.fn(async (_ctx: MsgContext, opts?: GetReplyOptions) => {
2082+
receivedOptions = opts;
2083+
return { text: "done" } satisfies ReplyPayload;
2084+
});
2085+
2086+
await dispatchReplyFromConfig({
2087+
ctx,
2088+
cfg: emptyConfig,
2089+
dispatcher,
2090+
replyResolver,
2091+
});
2092+
2093+
expect(receivedOptions?.suppressToolErrorWarnings).toBe(true);
2094+
expect(dispatcher.sendFinalReply).toHaveBeenCalledWith({ text: "done" });
2095+
});
2096+
2097+
it("keeps terminal tool-error fallbacks available in verbose full mode", async () => {
2098+
setNoAbort();
2099+
sessionStoreMocks.currentEntry = {
2100+
sessionId: "s1",
2101+
updatedAt: 0,
2102+
sendPolicy: "allow",
2103+
verboseLevel: "full",
2104+
};
2105+
const dispatcher = createDispatcher();
2106+
const ctx = buildTestCtx({
2107+
Provider: "telegram",
2108+
ChatType: "direct",
2109+
SessionKey: "agent:main:telegram:direct:U1",
2110+
});
2111+
let receivedOptions: GetReplyOptions | undefined;
2112+
const replyResolver = vi.fn(async (_ctx: MsgContext, opts?: GetReplyOptions) => {
2113+
receivedOptions = opts;
2114+
return { text: "done" } satisfies ReplyPayload;
2115+
});
2116+
2117+
await dispatchReplyFromConfig({
2118+
ctx,
2119+
cfg: emptyConfig,
2120+
dispatcher,
2121+
replyResolver,
2122+
});
2123+
2124+
expect(receivedOptions?.suppressToolErrorWarnings).toBeUndefined();
2125+
expect(dispatcher.sendFinalReply).toHaveBeenCalledWith({ text: "done" });
2126+
});
2127+
20662128
it("delivers text-only tool summaries when verbose overrides preview suppression", async () => {
20672129
setNoAbort();
20682130
sessionStoreMocks.currentEntry = {

src/auto-reply/reply/dispatch-from-config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,15 @@ export async function dispatchReplyFromConfig(
15691569
const shouldSuppressProgressDelivery = () =>
15701570
sendPolicyDenied ||
15711571
(suppressDelivery && !shouldDeliverVerboseProgressDespiteSourceSuppression());
1572+
const hasVisibleRegularVerboseToolProgress =
1573+
shouldEmitVerboseProgress() &&
1574+
!shouldEmitFullVerboseProgress() &&
1575+
shouldSendVerboseProgressMessages &&
1576+
ctx.InboundEventKind !== "room_event" &&
1577+
!shouldSuppressProgressDelivery();
1578+
const suppressToolErrorWarnings =
1579+
params.replyOptions?.suppressToolErrorWarnings ??
1580+
(hasVisibleRegularVerboseToolProgress ? true : undefined);
15721581
const onToolResultFromReplyOptions = params.replyOptions?.onToolResult;
15731582
const onPlanUpdateFromReplyOptions = params.replyOptions?.onPlanUpdate;
15741583
const onApprovalEventFromReplyOptions = params.replyOptions?.onApprovalEvent;
@@ -1609,6 +1618,7 @@ export async function dispatchReplyFromConfig(
16091618
{
16101619
...params.replyOptions,
16111620
sourceReplyDeliveryMode,
1621+
suppressToolErrorWarnings,
16121622
typingPolicy: typing.typingPolicy,
16131623
suppressTyping: typing.suppressTyping,
16141624
onPartialReply: wrapProgressCallback(params.replyOptions?.onPartialReply),

0 commit comments

Comments
 (0)