#7584: Tests: align subagent announce wait expectations
agents
Cluster:
Subagent Enhancements and Features
## 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
#13303: feat(subagents): replace silent boolean with announce enum ('user'|...
by ivalsaraj · 2026-02-10
83.8%
#13105: fix: debounce subagent lifecycle events to prevent premature announ...
by mcaxtr · 2026-02-10
82.0%
#14734: test(agents): guard against stale allowAgents in existing sessions
by davidahmann · 2026-02-12
81.4%
#23166: fix(agents): restore subagent announce chain from #22223
by tyler6204 · 2026-02-22
80.7%
#20328: fix(agents): Add retry with exponential backoff for subagent announ...
by tiny-ship-it · 2026-02-18
79.6%
#19674: test: allow optional session key in subagent announce mock
by DmitryIschanko · 2026-02-18
79.5%
#23229: fix(subagent-announce): gate queued delivery on channel deliverabil...
by mcinteerj · 2026-02-22
77.5%
#18205: fix (agents): add periodic retry timer for failed subagent announces
by MegaPhoenix92 · 2026-02-16
77.4%
#23048: feat(session): add `announceDeliver` option to suppress auto-delive...
by nszhsl · 2026-02-21
77.4%
#8893: fix: enhance subagent error reporting with diagnostic context
by joetomasone · 2026-02-04
77.3%