Repository navigation
Commit af4589f
committed
fix(streaming): stop suppressing context errors and publish DONE once
StreamingTaskMessageContext.__aexit__ returned close()'s TaskMessage,
and a truthy __aexit__ return value suppresses the exception. An error
raised inside `async with streaming_task_message_context(...)` was
therefore swallowed: the caller carried on past the block, the
half-written message was persisted as DONE, and a Temporal activity saw
a success and never retried. __aexit__ now closes the context and
returns False, matching the convention the inference-call context
manager already follows.
Separately, stream_update() published an explicit StreamTaskMessageDone
itself and then called close(), which published a second DONE because
_is_closed was still False. Two DONE frames reached the stream, and
since close() drains the coalescing buffer before publishing, buffered
deltas could land after the first one. The Done branch now delegates to
close(), which reaps the buffer, publishes exactly one DONE and
persists. Full and delta handling are unchanged.
Verified with `uv run pytest -q -n 0` on
tests/lib/core/services/adk/test_streaming.py: the three added
regression tests fail before the fix (two "DID NOT RAISE RuntimeError",
one "expected exactly one DONE publish, got 2") and the file is 37
passed after. tests/lib/adk, tests/lib/core/harness,
tests/lib/test_claude_agents_hooks.py and the openai_agents
test_streaming_model.py suite stay green.1 parent 6d68f3a commit af4589f
2 files changed
Lines changed: 81 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | | - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
399 | 406 | | |
400 | 407 | | |
401 | 408 | | |
| |||
484 | 491 | | |
485 | 492 | | |
486 | 493 | | |
487 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
488 | 497 | | |
489 | 498 | | |
490 | 499 | | |
| |||
501 | 510 | | |
502 | 511 | | |
503 | 512 | | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
504 | 517 | | |
505 | 518 | | |
506 | 519 | | |
| |||
511 | 524 | | |
512 | 525 | | |
513 | 526 | | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
| 527 | + | |
518 | 528 | | |
519 | 529 | | |
520 | 530 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | | - | |
| 66 | + | |
| 67 | + | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| |||
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
84 | 91 | | |
85 | 92 | | |
86 | 93 | | |
| |||
597 | 604 | | |
598 | 605 | | |
599 | 606 | | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
0 commit comments