



















@@ -113,17 +113,26 @@ describe("exec approval followup", () => {
113113expect(sendMessage).not.toHaveBeenCalled();
114114});
115115116-it("suppresses denied followups for normal sessions", async () => {
117-await expect(
118-sendExecApprovalFollowup({
119-approvalId: "req-denied-main",
120-sessionKey: "agent:main:main",
121-turnSourceChannel: "webchat",
122-resultText: "Exec denied (gateway id=req-denied-main, user-denied): uname -a",
123-}),
124-).resolves.toBe(false);
116+it("routes denied followups through the originating main session", async () => {
117+await sendExecApprovalFollowup({
118+approvalId: "req-denied-main",
119+sessionKey: "agent:main:main",
120+turnSourceChannel: "webchat",
121+resultText: "Exec denied (gateway id=req-denied-main, user-denied): uname -a",
122+});
125123126-expect(callGatewayTool).not.toHaveBeenCalled();
124+const agentArgs = expectGatewayAgentFollowup({
125+sessionKey: "agent:main:main",
126+deliver: false,
127+channel: "webchat",
128+idempotencyKey: "exec-approval-followup:req-denied-main",
129+});
130+expect(agentArgs.message).toContain("An async command did not run.");
131+expect(agentArgs.message).toContain(
132+"Exec denied (gateway id=req-denied-main, user-denied): uname -a",
133+);
134+expect(agentArgs.message).not.toContain("missing tool result");
135+expect(agentArgs.message).not.toContain("transcript repair");
127136expect(sendMessage).not.toHaveBeenCalled();
128137});
129138@@ -287,7 +296,9 @@ describe("exec approval followup", () => {
287296});
288297});
289298290-it("uses safe direct denied copy without resuming the session", async () => {
299+it("falls back to safe direct denied copy when session resume fails", async () => {
300+vi.mocked(callGatewayTool).mockRejectedValueOnce(new Error("session missing"));
301+291302await sendExecApprovalFollowup({
292303approvalId: "req-denied-resume-failed",
293304sessionKey: "agent:main:telegram:-100123",
@@ -302,10 +313,12 @@ describe("exec approval followup", () => {
302313content: "Command did not run: approval timed out.",
303314idempotencyKey: "exec-approval-followup:req-denied-resume-failed",
304315});
305-expect(callGatewayTool).not.toHaveBeenCalled();
316+expect(callGatewayTool).toHaveBeenCalledTimes(1);
306317});
307318308-it("uses safe direct denied copy for nested-parentheses denial metadata without resuming the session", async () => {
319+it("falls back to safe direct denied copy for nested-parentheses denial metadata", async () => {
320+vi.mocked(callGatewayTool).mockRejectedValueOnce(new Error("session missing"));
321+309322await sendExecApprovalFollowup({
310323approvalId: "req-denied-resume-failed-nested",
311324sessionKey: "agent:main:telegram:-100123",
@@ -321,7 +334,7 @@ describe("exec approval followup", () => {
321334content: "Command did not run: approval timed out.",
322335idempotencyKey: "exec-approval-followup:req-denied-resume-failed-nested",
323336});
324-expect(callGatewayTool).not.toHaveBeenCalled();
337+expect(callGatewayTool).toHaveBeenCalledTimes(1);
325338});
326339327340it("suppresses denied followups for subagent sessions", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。