#19679: fix: handle optional sessionKey in subagent-announce test mock
agents
size: XS
Cluster:
Subagent Task Management Fixes
## Summary
- Problem: `tsc` fails on `src/agents/subagent-announce.format.e2e.test.ts` line 71 — `typed.params?.sessionKey` is `string | undefined` but `chatHistoryMock` expects `string`.
- Why it matters: Breaks the `check` CI job on main, blocking all PRs.
- What changed: Added `?? ""` fallback so undefined becomes empty string.
- What did NOT change (scope boundary): No behavioral change — sessionKey is always present in practice.
## Change Type (select all)
- [x] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Docs
- [ ] Security hardening
- [ ] Chore/infra
## Scope (select all touched areas)
- [ ] Gateway / orchestration
- [ ] Skills / tool execution
- [ ] Auth / tokens
- [ ] Memory / storage
- [ ] Integrations
- [ ] API / contracts
- [ ] UI / DX
- [x] CI/CD / infra
## Linked Issue/PR
- Closes #19686
## User-visible / Behavior Changes
None — test-only change.
## Security Impact (required)
- New permissions/capabilities? `No`
- Secrets/tokens handling changed? `No`
- New/changed network calls? `No`
- Command/tool execution surface changed? `No`
- Data access scope changed? `No`
## Repro + Verification
### Environment
- OS: Any (CI runs on ubuntu-latest)
- Runtime/container: Node.js 22+ with TypeScript 5.x
- Model/provider: N/A (test-only change)
- Integration/channel: N/A
- Relevant config: N/A
### Steps
1. Run `pnpm check` (or `tsgo`) on main branch
2. Observe TS2345 error on `src/agents/subagent-announce.format.e2e.test.ts` line 71
3. Apply the `?? ""` fix and re-run `pnpm check`
### Expected
- `pnpm check` passes with no type errors
### Actual (before fix)
- `pnpm check` fails with: `error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.`
## Evidence
- [x] Failing test/log before + passing after
- [ ] Trace/log snippets
- [ ] Screenshot/recording
- [ ] Perf numbers (if relevant)
TypeScript compilation fails before the fix and passes after. CI job `check` confirms.
## Human Verification (required)
- Verified scenarios: The TypeScript error is resolved by providing a fallback value
- Edge cases checked: sessionKey is always present in test call sites
- What you did **not** verify: Full CI run (submitting to trigger it)
## Compatibility / Migration
- Backward compatible? `Yes`
- Config/env changes? `No`
- Migration needed? `No`
## Failure Recovery (if this breaks)
- How to disable/revert: Revert the one-line change
- Files/config to restore: `src/agents/subagent-announce.format.e2e.test.ts`
- Known bad symptoms: None expected
## Risks and Mitigations
None — one-character change in a test file.
## AI-assisted
This PR was AI-assisted. The code is understood and verified.
Most Similar PRs
#19674: test: allow optional session key in subagent announce mock
by DmitryIschanko · 2026-02-18
78.9%
#19177: fix: use parseAgentSessionKey instead of fragile split pattern
by El-Patronum · 2026-02-17
71.0%
#8471: fix(subagent): add defensive checks for undefined string fields
by adam-smeth · 2026-02-04
70.5%
#19636: fix(agents): harden overflow recovery observability + subagent term...
by Jackten · 2026-02-18
70.3%
#17393: fix(ci): resolve TS2742 type error blocking all PRs
by miloudbelarebia · 2026-02-15
69.5%
#22098: fix: isolate agent sessions by explicit --session-id
by AIflow-Labs · 2026-02-20
69.3%
#16949: fix(gateway): deliver chat:final even when sessionKey is unresolved (…
by ekleziast · 2026-02-15
68.7%
#22283: Plugins: expose resolveMainSessionKey in runtime system
by MegaPhoenix92 · 2026-02-21
68.5%
#22982: fix: prevent stale threadId from routing subagent announces to wron...
by unboxed-ai · 2026-02-21
68.5%
#20415: fix(extensions): use dist/ import paths for bundled extensions
by 88plug · 2026-02-18
68.4%