Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Dec 19, 2025

When a trigger mutates state in __on_workflow_fulfilled__ (e.g., ChatMessageTrigger appending the assistant message to chat_history), the snapshottable list pushes a WorkflowExecutionSnapshottedEvent onto _workflow_event_inner_queue. Previously, these events were dropped because the inner queue was not drained after the trigger hook. This fix adds draining of the inner queue after __on_workflow_fulfilled__ to ensure snapshot events are forwarded to the outer queue and observable by stream consumers (when using all_workflow_event_filter).

Note: Draining after __on_workflow_initiated__ is not needed because those snapshot events are already processed by the main event loop before it exits.


Review & Testing Checklist for Human

  • Verify the drain logic after __on_workflow_fulfilled__ doesn't introduce event ordering issues - snapshot events should appear before the fulfilled event
  • Confirm that NOT draining after __on_workflow_initiated__ is correct - the test asserts snapshot_events[0] contains just the user message, which could be brittle if event ordering changes
  • Test with a workflow using ChatMessageTrigger and verify both snapshot events (user message and assistant message) are visible when streaming with all_workflow_event_filter

Test Plan:

pytest tests/workflows/chat_message_trigger_execution/tests/test_chat_message_trigger_execution.py -v

Notes

The default workflow_event_filter intentionally excludes snapshot events - consumers must use all_workflow_event_filter or a custom filter to observe them.


When a trigger mutates state in __on_workflow_initiated__ or
__on_workflow_fulfilled__ (e.g., ChatMessageTrigger appending to
chat_history), the snapshottable list writes push a
WorkflowExecutionSnapshottedEvent onto _workflow_event_inner_queue.

Previously, these events were dropped because the inner queue was not
drained after the trigger hooks. This commit adds draining of the inner
queue after both trigger hooks to ensure snapshot events are forwarded
to the outer queue and observable by stream consumers.

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration bot and others added 4 commits December 19, 2025 17:58
…tiated__ and improve test assertions

- Removed the drain after __on_workflow_initiated__ since snapshot events
  from that hook are already processed by the main event loop
- Updated test to assert chat_history contents directly using tuple
  comparison for better readability and pytest diffs

Co-Authored-By: [email protected] <[email protected]>
Use ChatMessage objects directly in assertion for better readability
and pytest diffs on failure.

Co-Authored-By: [email protected] <[email protected]>
Verify that the snapshot event from __on_workflow_initiated__ (with just
the user message) is captured, proving the drain after initiated is not
needed since the main event loop already processes it.

Co-Authored-By: [email protected] <[email protected]>
Use snapshot_events[0] and assert chat_history directly, matching the
style of the last_snapshot assertion.

Co-Authored-By: [email protected] <[email protected]>
@vincent0426 vincent0426 marked this pull request as ready for review December 19, 2025 18:24
@vincent0426 vincent0426 merged commit 7a2a7a7 into main Dec 23, 2025
9 checks passed
@vincent0426 vincent0426 deleted the devin/1766166151-fix-trigger-snapshot-events branch December 23, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants