-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Description:
The on_event_callback plugin hook is executed after the event has already been saved to the database via session_service.append_event(). This means any modifications made to events by plugins (e.g., adding/modifying custom_metadata) are only visible in the yielded event stream but are not persisted to the database.
Current Behavior:
In runners.py (lines ~767-777):
if event.partial is not True:
await self.session_service.append_event(session=session, event=event)
# Step 3: Run the on_event callbacks to optionally modify the event.
modified_event = await plugin_manager.run_on_event_callback(
invocation_context=invocation_context, event=event
)
yield (modified_event if modified_event else event)This causes:
- ✅ Event saved to DB (without plugin modifications)
- ✅ Plugin modifies event via
on_event_callback - ✅ Modified event yielded to client (client sees modifications)
- ❌ DB still contains original unmodified event (subsequent reads missing modifications)
Expected Behavior:
Plugin modifications to events via on_event_callback should be persisted to the database so that:
- Real-time event stream and historical event retrieval return consistent data
- Custom metadata added by plugins is preserved across sessions
Use Case:
We have a plugin that enriches events with contextual metadata (execution phase, workflow state) which is essential for our UI to display proper state. Currently, this metadata is only visible during initial streaming but disappears when fetching conversation history.