惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

有赞技术团队
有赞技术团队
Martin Fowler
Martin Fowler
N
Netflix TechBlog - Medium
WordPress大学
WordPress大学
罗磊的独立博客
H
Help Net Security
MongoDB | Blog
MongoDB | Blog
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
Docker
云风的 BLOG
云风的 BLOG
Microsoft Security Blog
Microsoft Security Blog
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
InfoQ
J
Java Code Geeks
博客园 - 聂微东
大猫的无限游戏
大猫的无限游戏
Engineering at Meta
Engineering at Meta
美团技术团队
小众软件
小众软件
Stack Overflow Blog
Stack Overflow Blog
C
Check Point Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(agents): preserve suspended subagent final deliveries...
joshavant · 2026-05-17 · via Recent Commits to openclaw:main

@@ -1,6 +1,10 @@

11

import { beforeEach, describe, expect, it, vi } from "vitest";

22

import type { CallGatewayOptions } from "../gateway/call.js";

3-

import { SUBAGENT_ENDED_REASON_COMPLETE } from "./subagent-lifecycle-events.js";

3+

import {

4+

SUBAGENT_ENDED_REASON_COMPLETE,

5+

SUBAGENT_ENDED_REASON_ERROR,

6+

SUBAGENT_ENDED_REASON_KILLED,

7+

} from "./subagent-lifecycle-events.js";

48

import { createSubagentRegistryLifecycleController } from "./subagent-registry-lifecycle.js";

59

import type { SubagentRunRecord } from "./subagent-registry.types.js";

610

@@ -653,6 +657,102 @@ describe("subagent registry lifecycle hardening", () => {

653657

expect(Number.isNaN(entry.cleanupCompletedAt)).toBe(false);

654658

});

655659660+

it("suspends successful keep-mode final delivery instead of completing cleanup on retry exhaustion", async () => {

661+

const persist = vi.fn();

662+

const entry = createRunEntry({

663+

endedAt: 4_000,

664+

endedReason: SUBAGENT_ENDED_REASON_COMPLETE,

665+

expectsCompletionMessage: true,

666+

frozenResultText: "final answer",

667+

lastAnnounceDeliveryError: "gateway request timeout for agent",

668+

outcome: { status: "ok" },

669+

retainAttachmentsOnKeep: true,

670+

});

671+672+

const controller = createLifecycleController({

673+

entry,

674+

persist,

675+

captureSubagentCompletionReply: vi.fn(async () => undefined),

676+

});

677+678+

await controller.finalizeResumedAnnounceGiveUp({

679+

runId: entry.runId,

680+

entry,

681+

reason: "retry-limit",

682+

});

683+684+

expect(entry.pendingFinalDelivery).toBe(true);

685+

expect(entry.pendingFinalDeliveryPayload).toMatchObject({

686+

requesterSessionKey: entry.requesterSessionKey,

687+

childSessionKey: entry.childSessionKey,

688+

childRunId: entry.runId,

689+

frozenResultText: "final answer",

690+

});

691+

expect(entry.deliverySuspendedAt).toBeTypeOf("number");

692+

expect(entry.deliverySuspendedReason).toBe("retry-limit");

693+

expect(entry.cleanupHandled).toBe(false);

694+

expect(entry.cleanupCompletedAt).toBeUndefined();

695+

expect(helperMocks.safeRemoveAttachmentsDir).not.toHaveBeenCalled();

696+

expectFields(firstCallArg(taskExecutorMocks.setDetachedTaskDeliveryStatusByRunId), {

697+

runId: entry.runId,

698+

runtime: "subagent",

699+

sessionKey: entry.childSessionKey,

700+

deliveryStatus: "failed",

701+

error: "gateway request timeout for agent",

702+

});

703+

expect(persist).toHaveBeenCalled();

704+

});

705+706+

it.each([

707+

{

708+

name: "timeout",

709+

endedReason: SUBAGENT_ENDED_REASON_COMPLETE,

710+

outcome: { status: "timeout" as const },

711+

},

712+

{

713+

name: "error",

714+

endedReason: SUBAGENT_ENDED_REASON_ERROR,

715+

outcome: { status: "error" as const, error: "child failed" },

716+

},

717+

{

718+

name: "killed",

719+

endedReason: SUBAGENT_ENDED_REASON_KILLED,

720+

outcome: undefined,

721+

},

722+

])(

723+

"keeps $name completion cleanup terminal on retry exhaustion",

724+

async ({ endedReason, outcome }) => {

725+

const persist = vi.fn();

726+

const entry = createRunEntry({

727+

endedAt: 4_000,

728+

endedReason,

729+

expectsCompletionMessage: true,

730+

lastAnnounceDeliveryError: "gateway request timeout for agent",

731+

outcome,

732+

retainAttachmentsOnKeep: true,

733+

});

734+735+

const controller = createLifecycleController({

736+

entry,

737+

persist,

738+

captureSubagentCompletionReply: vi.fn(async () => undefined),

739+

});

740+741+

await controller.finalizeResumedAnnounceGiveUp({

742+

runId: entry.runId,

743+

entry,

744+

reason: "retry-limit",

745+

});

746+747+

expect(entry.pendingFinalDelivery).toBeUndefined();

748+

expect(entry.pendingFinalDeliveryPayload).toBeUndefined();

749+

expect(entry.deliverySuspendedAt).toBeUndefined();

750+

expect(entry.deliverySuspendedReason).toBeUndefined();

751+

expect(entry.cleanupCompletedAt).toBeTypeOf("number");

752+

expect(persist).toHaveBeenCalled();

753+

},

754+

);

755+656756

it("continues cleanup when delivery-status persistence throws after announce delivery", async () => {

657757

const persist = vi.fn();

658758

const warn = vi.fn();

@@ -767,7 +867,15 @@ describe("subagent registry lifecycle hardening", () => {

767867

expect(entry.lastAnnounceDeliveryError).toBe(

768868

"UNAVAILABLE: requester wake failed; direct-primary: UNAVAILABLE: requester wake failed",

769869

);

770-

expect(entry.cleanupCompletedAt).toBeTypeOf("number");

870+

expect(entry.pendingFinalDelivery).toBe(true);

871+

expect(entry.pendingFinalDeliveryPayload).toMatchObject({

872+

requesterSessionKey: entry.requesterSessionKey,

873+

childSessionKey: entry.childSessionKey,

874+

childRunId: entry.runId,

875+

});

876+

expect(entry.deliverySuspendedAt).toBeTypeOf("number");

877+

expect(entry.deliverySuspendedReason).toBe("retry-limit");

878+

expect(entry.cleanupCompletedAt).toBeUndefined();

771879

expect(persist).toHaveBeenCalled();

772880

});

773881