diff --git a/src/commands/agent-via-gateway.test.ts b/src/commands/agent-via-gateway.test.ts index 15ba8f0c677..118e7af4027 100644 --- a/src/commands/agent-via-gateway.test.ts +++ b/src/commands/agent-via-gateway.test.ts @@ -107,6 +107,21 @@ describe("agentCliCommand", () => { }); }); + it("suppresses silent gateway summaries when no payloads are returned", async () => { + await withTempStore(async () => { + vi.mocked(callGateway).mockResolvedValue({ + runId: "idem-1", + status: "ok", + summary: " ANNOUNCE_SKIP ", + result: { payloads: [], meta: { stub: true } }, + }); + + await agentCliCommand({ message: "hi", to: "+1555" }, runtime); + + expect(runtime.log).not.toHaveBeenCalled(); + }); + }); + it("falls back to embedded agent when gateway fails", async () => { await withTempStore(async () => { vi.mocked(callGateway).mockRejectedValue(new Error("gateway not connected")); diff --git a/src/commands/agent-via-gateway.ts b/src/commands/agent-via-gateway.ts index 79e05cc6047..3b4111b723b 100644 --- a/src/commands/agent-via-gateway.ts +++ b/src/commands/agent-via-gateway.ts @@ -15,6 +15,8 @@ import { import { agentCommand } from "./agent.js"; import { resolveSessionKeyForRequest } from "./agent/session.js"; +const SILENT_AGENT_SUMMARIES = new Set(["NO_REPLY", "ANNOUNCE_SKIP"]); + type AgentGatewayResult = { payloads?: Array<{ text?: string; @@ -33,6 +35,11 @@ type GatewayAgentResponse = { const NO_GATEWAY_TIMEOUT_MS = 2_147_000_000; +function isSilentAgentSummary(text: string | undefined): boolean { + const normalized = text?.trim(); + return normalized ? SILENT_AGENT_SUMMARIES.has(normalized) : false; +} + export type AgentCliOpts = { message: string; agent?: string; @@ -164,7 +171,10 @@ export async function agentViaGatewayCommand(opts: AgentCliOpts, runtime: Runtim const payloads = result?.payloads ?? []; if (payloads.length === 0) { - runtime.log(response?.summary ? String(response.summary) : "No reply from agent."); + const summary = response?.summary ? String(response.summary) : undefined; + if (!isSilentAgentSummary(summary)) { + runtime.log(summary ?? "No reply from agent."); + } return response; }