Commit cca0dbb
Refactor streaming architecture to fix agent content attribution
Implemented robust tool XML filtering and agent content routing to resolve
issues with nested agent streaming where output was being lost, duplicated,
or incorrectly attributed.
Key improvements:
- SDK: Rewrote tool XML filtering with proper state machines and partial tag
matching to handle streaming text at buffer boundaries without data loss
- Backend: Modified spawn-agents to route text chunks through sendSubagentChunk
and forward print mode events with agent IDs for proper attribution
- CLI: Enhanced agent content tracking with duplicate detection, proper content
field synchronization, and comprehensive logging for debugging
- Dev: Simplified development workflow by running CLI directly via bun
- Cleanup: Removed duplicate ToolName export from SDK
The new architecture ensures streaming content flows correctly through the
agent hierarchy, preventing edge cases where tool XML tags could corrupt
output or cause content to be misattributed to the wrong agent.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>1 parent e1711b7 commit cca0dbb
File tree
4 files changed
+275
-81
lines changed- backend/src/tools/handlers/tool
- cli/src/hooks
- sdk/src
4 files changed
+275
-81
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
154 | 158 | | |
155 | 159 | | |
156 | | - | |
157 | | - | |
158 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
159 | 163 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 164 | + | |
| 165 | + | |
164 | 166 | | |
165 | 167 | | |
166 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
160 | 169 | | |
161 | 170 | | |
162 | 171 | | |
| |||
168 | 177 | | |
169 | 178 | | |
170 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
171 | 187 | | |
172 | 188 | | |
173 | 189 | | |
174 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
175 | 198 | | |
176 | 199 | | |
| 200 | + | |
177 | 201 | | |
178 | 202 | | |
179 | 203 | | |
180 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
181 | 216 | | |
182 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
183 | 222 | | |
184 | 223 | | |
185 | 224 | | |
| |||
348 | 387 | | |
349 | 388 | | |
350 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
351 | 397 | | |
352 | 398 | | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
380 | 413 | | |
381 | 414 | | |
382 | 415 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
0 commit comments