Commit 14496d3
committed
refactor(server): migrate from AgentResult to AgentEvent for protocol agnostic design
This change migrates the core event handling system from AgentResult to AgentEvent,
providing a protocol-agnostic foundation that supports both OpenAI and AG-UI protocols.
The new AgentEvent system automatically handles boundary events (START/END) at the
protocol layer, simplifying user-facing event definitions and improving consistency
across different protocol implementations.
The migration includes:
- Replacing AgentResult with AgentEvent as the primary event type
- Introducing simplified event types (TEXT, TOOL_CALL, TOOL_RESULT)
- Removing manual boundary event handling from user code
- Adding automatic boundary event generation in protocol handlers
- Updating all integrations and tests to use the new event system
BREAKING CHANGE: AgentResult has been replaced with AgentEvent. Users must update
their event handling code to use the new event types and structure.
将服务器从 AgentResult 迁移到 AgentEvent,实现协议无关的设计
此次更改将核心事件处理系统从 AgentResult 迁移到 AgentEvent,
提供了支持 OpenAI 和 AG-UI 协议的协议无关基础。
新的 AgentEvent 系统在协议层自动处理边界事件(START/END),
简化了面向用户的事件定义并提高不同协议实现之间的一致性。
迁移包括:
- 将 AgentResult 替换为 AgentEvent 作为主要事件类型
- 引入简化的事件类型(TEXT、TOOL_CALL、TOOL_RESULT)
- 从用户代码中移除手动边界事件处理
- 在协议处理器中添加自动边界事件生成
- 更新所有集成和测试以使用新的事件系统
重大变更:AgentResult 已被 AgentEvent 替换。用户必须更新
他们的事件处理代码以使用新的事件类型和结构。
perf(langgraph): optimize tool call event conversion with chunk-based streaming
Improves the tool call event conversion process in LangGraph integration by
switching from multiple discrete events (START, ARGS, END) to a single
chunk-based approach (TOOL_CALL_CHUNK). This reduces event overhead and
simplifies the event flow while maintaining proper tool call ID consistency
and argument streaming capabilities.
The optimization includes:
- Consolidating tool call events into single chunks with complete args
- Maintaining proper tool call ID tracking across streaming chunks
- Supporting both complete and incremental argument transmission
- Preserving compatibility with existing LangGraph event formats
性能优化(langgraph): 使用基于块的流优化工具调用事件转换
通过从多个离散事件(START、ARGS、END)切换到单一块方法(TOOL_CALL_CHUNK),
改进 LangGraph 集成中的工具调用事件转换过程。
这减少了事件开销并简化了事件流,同时保持适当的工具调用 ID 一致性和
参数流功能。
优化包括:
- 将工具调用事件整合到包含完整参数的单个块中
- 在流块间保持适当的工具调用 ID 跟踪
- 支持完整和增量参数传输
- 保持与现有 LangGraph 事件格式的兼容性
test: add comprehensive test coverage for event conversion and protocol handling
Adds extensive test coverage for the new AgentEvent system and event conversion
functionality. Includes unit tests for LangGraph event conversion, protocol
handling, and edge cases. The test suite ensures proper behavior across
different event formats and verifies correct event ordering and ID consistency.
The new tests cover:
- LangGraph event conversion for different stream modes
- AG-UI event normalizer functionality
- Server protocol handling for both OpenAI and AG-UI
- Tool call ID consistency across streaming chunks
- Error handling and edge cases
测试: 为事件转换和协议处理添加全面的测试覆盖
为新的 AgentEvent 系统和事件转换功能添加广泛的测试覆盖。
包括 LangGraph 事件转换、协议处理和边缘情况的单元测试。
测试套件确保不同事件格式的正确行为,并验证正确的事件排序和 ID 一致性。
新测试覆盖:
- 不同流模式下的 LangGraph 事件转换
- AG-UI 事件规范化器功能
- 服务器协议处理(OpenAI 和 AG-UI)
- 流块间工具调用 ID 的一致性
- 错误处理和边缘情况
Change-Id: I92fca1758866344bd34486b853d177e7d8f9fdf4
Signed-off-by: OhYee <[email protected]>1 parent 8a19135 commit 14496d3
File tree
14 files changed
+3259
-1657
lines changed- agentrun
- integration/langgraph
- server
- tests/unittests
- integration
- server
14 files changed
+3259
-1657
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
| 388 | + | |
| 389 | + | |
395 | 390 | | |
396 | 391 | | |
397 | 392 | | |
398 | 393 | | |
399 | 394 | | |
400 | 395 | | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
405 | 404 | | |
406 | 405 | | |
407 | | - | |
| 406 | + | |
408 | 407 | | |
409 | 408 | | |
410 | 409 | | |
411 | 410 | | |
412 | | - | |
| 411 | + | |
413 | 412 | | |
414 | | - | |
| 413 | + | |
415 | 414 | | |
416 | 415 | | |
417 | 416 | | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | 417 | | |
423 | 418 | | |
424 | 419 | | |
| |||
454 | 449 | | |
455 | 450 | | |
456 | 451 | | |
457 | | - | |
| 452 | + | |
458 | 453 | | |
459 | 454 | | |
460 | 455 | | |
461 | 456 | | |
462 | 457 | | |
463 | 458 | | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
| 459 | + | |
| 460 | + | |
471 | 461 | | |
472 | 462 | | |
473 | 463 | | |
474 | 464 | | |
475 | 465 | | |
476 | 466 | | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
481 | 475 | | |
482 | 476 | | |
483 | 477 | | |
484 | 478 | | |
485 | 479 | | |
486 | 480 | | |
487 | | - | |
| 481 | + | |
488 | 482 | | |
489 | | - | |
| 483 | + | |
490 | 484 | | |
491 | 485 | | |
492 | 486 | | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | 487 | | |
498 | 488 | | |
499 | 489 | | |
| |||
559 | 549 | | |
560 | 550 | | |
561 | 551 | | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
566 | 558 | | |
567 | 559 | | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
| 560 | + | |
| 561 | + | |
578 | 562 | | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
583 | 574 | | |
584 | | - | |
585 | | - | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
586 | 595 | | |
587 | 596 | | |
588 | 597 | | |
| |||
598 | 607 | | |
599 | 608 | | |
600 | 609 | | |
| 610 | + | |
601 | 611 | | |
602 | 612 | | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
609 | 621 | | |
610 | | - | |
611 | | - | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
612 | 628 | | |
613 | 629 | | |
614 | 630 | | |
| |||
622 | 638 | | |
623 | 639 | | |
624 | 640 | | |
625 | | - | |
| 641 | + | |
626 | 642 | | |
627 | 643 | | |
628 | 644 | | |
629 | 645 | | |
630 | 646 | | |
631 | 647 | | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
| 648 | + | |
640 | 649 | | |
641 | 650 | | |
642 | 651 | | |
643 | | - | |
| 652 | + | |
644 | 653 | | |
645 | | - | |
| 654 | + | |
646 | 655 | | |
647 | 656 | | |
648 | 657 | | |
649 | 658 | | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
660 | 668 | | |
661 | 669 | | |
662 | 670 | | |
| |||
667 | 675 | | |
668 | 676 | | |
669 | 677 | | |
670 | | - | |
671 | | - | |
| 678 | + | |
672 | 679 | | |
673 | | - | |
| 680 | + | |
674 | 681 | | |
675 | | - | |
| 682 | + | |
676 | 683 | | |
677 | 684 | | |
678 | 685 | | |
| |||
0 commit comments