fix: land NO_REPLY announce suppression and auth scope assertions

Landed follow-up for #27535 and aligned shared-auth gateway expectations after #27498.

Co-authored-by: kevinWangSheng <118158941+kevinWangSheng@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-02-26 13:40:30 +00:00
parent eb9a968336
commit 96aad965ab
5 changed files with 50 additions and 18 deletions

View File

@@ -184,10 +184,16 @@ function isDirectOpenAIBaseUrl(baseUrl: unknown): boolean {
try {
const host = new URL(baseUrl).hostname.toLowerCase();
return host === "api.openai.com" || host === "chatgpt.com" || host.endsWith(".openai.azure.com");
return (
host === "api.openai.com" || host === "chatgpt.com" || host.endsWith(".openai.azure.com")
);
} catch {
const normalized = baseUrl.toLowerCase();
return normalized.includes("api.openai.com") || normalized.includes("chatgpt.com") || normalized.includes(".openai.azure.com");
return (
normalized.includes("api.openai.com") ||
normalized.includes("chatgpt.com") ||
normalized.includes(".openai.azure.com")
);
}
}

View File

@@ -435,6 +435,23 @@ describe("subagent announce formatting", () => {
expect(sessionsDeleteSpy).toHaveBeenCalledTimes(1);
});
it("suppresses completion delivery when subagent reply is NO_REPLY", async () => {
const didAnnounce = await runSubagentAnnounceFlow({
childSessionKey: "agent:main:subagent:test",
childRunId: "run-direct-completion-no-reply",
requesterSessionKey: "agent:main:main",
requesterDisplayKey: "main",
requesterOrigin: { channel: "slack", to: "channel:C123", accountId: "acct-1" },
...defaultOutcomeAnnounce,
expectsCompletionMessage: true,
roundOneReply: " NO_REPLY ",
});
expect(didAnnounce).toBe(true);
expect(sendSpy).not.toHaveBeenCalled();
expect(agentSpy).not.toHaveBeenCalled();
});
it("retries completion direct send on transient channel-unavailable errors", async () => {
sendSpy
.mockRejectedValueOnce(new Error("Error: No active WhatsApp Web listener (account: default)"))

View File

@@ -1,5 +1,5 @@
import { resolveQueueSettings } from "../auto-reply/reply/queue.js";
import { SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js";
import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js";
import { DEFAULT_SUBAGENT_MAX_SPAWN_DEPTH } from "../config/agent-limits.js";
import { loadConfig } from "../config/config.js";
import {
@@ -1161,6 +1161,9 @@ export async function runSubagentAnnounceFlow(params: {
if (isAnnounceSkip(reply)) {
return true;
}
if (isSilentReplyText(reply, SILENT_REPLY_TOKEN)) {
return true;
}
if (!outcome) {
outcome = { status: "unknown" };