docs: document subagent announce tests · openclaw/openclaw@ca24dd7
steipete
·
2026-06-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Subagent announce delivery tests cover the last-mile routing used when child |
| 2 | +// runs report progress or completion back to the requester session. |
1 | 3 | import { afterEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import { OutboundDeliveryError } from "../infra/outbound/deliver-types.js"; |
3 | 5 | import { |
@@ -86,6 +88,8 @@ function createQueueOutcomeMock(
|
86 | 88 | function createQueueOutcomeSequenceMock( |
87 | 89 | queuedOutcomes: (boolean | EmbeddedAgentQueueFailureReason)[], |
88 | 90 | ): ReturnType<typeof vi.fn<QueueEmbeddedAgentMessageWithOutcome>> { |
| 91 | +// Sequence mocks model retry paths where the embedded run can become |
| 92 | +// unavailable between announce attempts. |
89 | 93 | let index = 0; |
90 | 94 | return vi.fn((sessionId: string) => { |
91 | 95 | const outcome = queuedOutcomes[Math.min(index, queuedOutcomes.length - 1)] ?? false; |
@@ -187,6 +191,8 @@ async function deliverSlackThreadAnnouncement(params: {
|
187 | 191 | sourceTool?: string; |
188 | 192 | requesterAbandoned?: boolean; |
189 | 193 | }) { |
| 194 | +// Slack thread delivery exercises all origins because direct, session, and |
| 195 | +// completion routing can differ after a child run outlives its requester. |
190 | 196 | testing.setDepsForTest({ |
191 | 197 | callGateway: params.callGateway, |
192 | 198 | getRequesterSessionActivity: () => ({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Subagent announce dispatch tests lock down direct-vs-steer ordering for |
| 2 | +// progress updates and completion messages. |
1 | 3 | import { describe, expect, it, vi } from "vitest"; |
2 | 4 | import { |
3 | 5 | mapSteerOutcomeToDeliveryResult, |
@@ -112,6 +114,8 @@ describe("runSubagentAnnounceDispatch", () => {
|
112 | 114 | terminal: true, |
113 | 115 | })); |
114 | 116 | |
| 117 | +// Terminal direct failures can represent partial media delivery; fallback |
| 118 | +// steering would risk duplicate or contradictory completion messages. |
115 | 119 | const result = await runSubagentAnnounceDispatch({ |
116 | 120 | expectsCompletionMessage: true, |
117 | 121 | steer, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Subagent announce output tests cover transcript reads, completion extraction, |
| 2 | +// compact stats, and wait-outcome text used in announce messages. |
1 | 3 | import { afterEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import { |
3 | 5 | testing, |
@@ -30,6 +32,8 @@ function installOutputDeps(params: {
|
30 | 32 | } |
31 | 33 | |
32 | 34 | function sessionsYieldTurn(message = "Waiting for subagent completion.") { |
| 35 | +// sessions_yield is requester control flow, not child output; fixtures keep |
| 36 | +// that wait turn adjacent to later assistant completions. |
33 | 37 | return [ |
34 | 38 | { |
35 | 39 | role: "assistant", |
@@ -204,6 +208,8 @@ describe("readSubagentOutput", () => {
|
204 | 208 | ], |
205 | 209 | }); |
206 | 210 | |
| 211 | +// Private transcript data is fresher for recovered runs and avoids exposing |
| 212 | +// stale gateway-visible history after an internal completion is persisted. |
207 | 213 | await expect( |
208 | 214 | readSubagentOutput("agent:main:subagent:child", undefined, { |
209 | 215 | sessionFile: "/tmp/openclaw-internal-run.jsonl", |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Completion-reply capture tests cover the short polling window used to collect |
| 2 | +// final child output after an announce waits for the subagent. |
1 | 3 | import { describe, expect, it, vi } from "vitest"; |
2 | 4 | import { captureSubagentCompletionReplyUsing } from "./subagent-announce-capture.js"; |
3 | 5 | |
@@ -26,6 +28,8 @@ describe("captureSubagentCompletionReply", () => {
|
26 | 28 | .mockResolvedValueOnce(undefined) |
27 | 29 | .mockResolvedValueOnce("Late tool result completion"); |
28 | 30 | |
| 31 | +// Fake timers make the retry contract deterministic without waiting for the |
| 32 | +// wall-clock window used by live child sessions. |
29 | 33 | const pending = captureSubagentCompletionReplyUsing({ |
30 | 34 | sessionKey: "agent:main:subagent:child", |
31 | 35 | maxWaitMs: 50, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。