Merge ab8913f2c0d0688f2c59757e95188c81d463de2c into 5e417b44e1540f528d2ae63e3e20229a902d1db2
This commit is contained in:
commit
86bfa180bd
@ -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"));
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user