Commit 152b98d
authored
fix(examples): reject incomplete multi-agent streams (#2666)
## Summary
Require a coordinator `response.completed` event before the multi-agent
SSE example treats stream termination as success. The production change
is six added lines in the handwritten example.
Child-agent completion/failure remains nonterminal for the coordinator.
The example still consumes the stream after coordinator completion,
preserving explicit root failures, named SSE errors, and transport
errors rather than hiding them with an early break.
## Reproduction
On current main, the actual executable example exits successfully when
the server sends `[DONE]` or closes the SSE body before the coordinator
completes—even with only partial coordinator text or a completed/failed
child agent. Ten new executable regressions fail before the source
change, while fourteen controls pass.
## Validation
- Final example suite: 25/25 tests pass on exact Node 22.0.0, Node
24.19.0, and Node 26.7.0.
- Covers empty/partial/child-only EOF and `[DONE]`,
omitted/null/explicit root ownership, child-status continuation, and a
named SSE error received after coordinator completion.
- Independent public built CommonJS/ESM checks pass on Node 22/24/26,
including later root failures, malformed SSE, transport-error identity,
output preservation, and existing sentinel behavior.
- Full canonical handwritten suite: 7,817 tests pass across 205 files.
- Canonical format, lint, TypeScript checking, build, and `git diff
--check` pass. The entire built SDK is byte-for-byte identical to the
base build.
- Adversarial review completed against the final source and test hashes
with no remaining findings.
Only the example and its existing regression-test file change. No SDK
runtime/parser changes, generated files, dependencies, new payload
limits, or WebSocket changes. All inputs and responses are synthetic; no
live API calls. This complements the existing explicit-terminal-error
handling and the separate WebSocket early-close fix.1 parent a11bb1b commit 152b98d
2 files changed
Lines changed: 66 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
| 36 | + | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
134 | 174 | | |
135 | 175 | | |
136 | 176 | | |
| |||
162 | 202 | | |
163 | 203 | | |
164 | 204 | | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
175 | 218 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
0 commit comments