← Back to PRs

#7584: Tests: align subagent announce wait expectations

by justinhuangcode open 2026-02-03 00:41 View on GitHub →
agents
## Summary - update sessions_spawn announce lifecycle test to match new announce-step flow - mock announce-step helpers so delivery happens via send/chat.inject instead of a second agent call ## Testing - pnpm vitest run --config vitest.unit.config.ts src/agents/openclaw-tools.subagents.sessions-spawn-announces-agent-wait-lifecycle-events.test.ts ## Notes - fixes the failing test in #7556 (subagent announce changes) AI-assisted: Yes (Codex). Prompts/session logs available on request. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates subagent announce-related tests to match the newer “announce step” flow: instead of a second `callGateway({ method: "agent", deliver: true })` call, the code now generates a summary via `runAgentStep()` and delivers it through `send`/`chat.inject`. The tests were updated to mock `runAgentStep`/`readLatestAssistantReply` and to assert a single `agent` spawn call plus one delivery call. The main functional change in this diff is in `src/agents/subagent-announce.ts`, which introduces `deliverAnnounce()` (enforces send policy and chooses between `send` vs `chat.inject`) and uses a derived announce session key (`agent:${agentId}:announce:${hash}`). <h3>Confidence Score: 3/5</h3> - This PR is likely safe to merge, but there are a couple of logic/test-consistency issues worth fixing first. - Most changes are test alignment plus a straightforward refactor of announce delivery. However, there’s dead/duplicated logic in the announce outcome handling, and at least one test has contradictory setup (mocking a removed path). A few tests also don’t explicitly mock/assert the new `send`/`chat.inject` delivery calls, which can lead to brittleness. - src/agents/subagent-announce.ts, src/agents/subagent-announce.format.test.ts, src/agents/openclaw-tools.subagents.sessions-spawn-normalizes-allowlisted-agent-ids.test.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs