Commit a5ce8ab
authored
feat(runtime, react): Explicit error handling and retires for IntelligenceAgent* (CopilotKit#3379)
<!--
Thank you for sending the PR! We appreciate you spending the time to
work on these changes.
Help us understand your motivation by explaining why you decided to make
this change.
**Please PLEASE reach out to us first before starting any significant
work on new or existing features.**
By the time you've gotten here, you're looking at creating a pull
request so hopefully we're not too late.
We love community contributions! That said, we want to make sure we're
all on the same page before you start.
Investing a lot of time and effort just to find out it doesn't align
with the upstream project feels awful, and we don't want that to happen.
It also helps to make sure the work you're planning isn't already in
progress.
As described in our contributing guide, please file an issue first:
https://github.com/ag-ui-protocol/ag-ui/issues
Or, reach out to us on Discord: https://discord.com/invite/6dffbvGU3D
You can learn more about contributing to copilotkit here:
https://github.com/copilotkit/copilotkit/blob/master/CONTRIBUTING.md
Happy contributing!
-->
## What does this PR do?
This PR expands on reconnection and error handling for the
IntelligenceAgent and IntelligenceAgentRunner interactions with the
Phoenix lib/server, like timeouts and disconnects.
It explicitly defines exponential backoff behavior (Phoenix has default
settings, but they are silently disabled if you add error callbacks.
While that was only done in the AgentRunner to begin with, it felt
strange to leave it as a foot gun elsewhere).
There is also added logic to ensure cleanup messages are sent (at best
effort) before channels are closed.
Additionally:
* each agent run through the IntelligenceAgentRunner now gets its own
web socket connection (before, it only got its own _channel_)
* the IntelligenceAgent now stops a running agent by publishing a stop
(custom AG-UI) message to Phoenix, which is handled by the
IntelligenceAgentRunner.
## Related PRs and Issues
- https://linear.app/copilotkit/issue/ENT-54
- https://linear.app/copilotkit/issue/ENT-59
## Checklist
- [ ] I have read the [Contribution
Guide](https://github.com/copilotkit/copilotkit/blob/master/CONTRIBUTING.md)
- [ ] If the PR changes or adds functionality, I have updated the
relevant documentation6 files changed
Lines changed: 763 additions & 112 deletions
File tree
- packages/v2
- core/src
- __tests__
- runtime/src/runner
- __tests__
Lines changed: 205 additions & 47 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
260 | 367 | | |
261 | 368 | | |
262 | 369 | | |
| |||
286 | 393 | | |
287 | 394 | | |
288 | 395 | | |
289 | | - | |
| 396 | + | |
290 | 397 | | |
291 | 398 | | |
292 | 399 | | |
293 | 400 | | |
294 | 401 | | |
295 | 402 | | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | 403 | | |
301 | 404 | | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
309 | 414 | | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
310 | 434 | | |
311 | | - | |
312 | 435 | | |
313 | 436 | | |
314 | 437 | | |
315 | | - | |
| 438 | + | |
316 | 439 | | |
317 | 440 | | |
318 | 441 | | |
319 | 442 | | |
320 | 443 | | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
321 | 450 | | |
322 | | - | |
323 | | - | |
324 | 451 | | |
325 | 452 | | |
326 | 453 | | |
327 | | - | |
| 454 | + | |
328 | 455 | | |
329 | 456 | | |
330 | 457 | | |
331 | 458 | | |
332 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
333 | 466 | | |
334 | | - | |
335 | | - | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
336 | 474 | | |
| 475 | + | |
| 476 | + | |
337 | 477 | | |
338 | 478 | | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
344 | 487 | | |
345 | 488 | | |
346 | | - | |
| 489 | + | |
347 | 490 | | |
348 | | - | |
| 491 | + | |
349 | 492 | | |
350 | 493 | | |
351 | 494 | | |
| |||
387 | 530 | | |
388 | 531 | | |
389 | 532 | | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | 533 | | |
412 | 534 | | |
413 | 535 | | |
| |||
534 | 656 | | |
535 | 657 | | |
536 | 658 | | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
537 | 695 | | |
538 | 696 | | |
539 | 697 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
| 288 | + | |
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| 293 | + | |
293 | 294 | | |
294 | 295 | | |
295 | 296 | | |
| |||
304 | 305 | | |
305 | 306 | | |
306 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
307 | 312 | | |
308 | 313 | | |
309 | 314 | | |
310 | 315 | | |
311 | 316 | | |
312 | | - | |
313 | | - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
314 | 320 | | |
315 | 321 | | |
316 | 322 | | |
| |||
328 | 334 | | |
329 | 335 | | |
330 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
331 | 342 | | |
332 | 343 | | |
333 | 344 | | |
| |||
337 | 348 | | |
338 | 349 | | |
339 | 350 | | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
340 | 354 | | |
341 | 355 | | |
342 | 356 | | |
| |||
350 | 364 | | |
351 | 365 | | |
352 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
353 | 375 | | |
354 | 376 | | |
355 | 377 | | |
356 | 378 | | |
357 | 379 | | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
358 | 390 | | |
0 commit comments