fix(llama-index): Suppress unhandled event warnings for SparseEmbeddingEndEvent and Workflow*OutputEvent#2908
Conversation
…events Registers singledispatch handlers for four previously unhandled event types that were producing spurious WARNING logs: WARNING - Unhandled event of type SparseEmbeddingEndEvent WARNING - Unhandled event of type WorkflowStepOutputEvent WARNING - Unhandled event of type WorkflowRunOutputEvent WARNING - Unhandled event of type SpanCancelledEvent (pre-emptive) SparseEmbeddingEndEvent (llama-index-core): Sparse embedding vectors are Dict[int, float] (token-id → weight), incompatible with the EMBEDDING_VECTOR attribute (List[float]). The handler records the text chunks and skips the vectors, keeping the span populated without violating the semantic convention. Note: SparseEmbeddingStartEvent no longer needs a handler here because a companion fix in llama-index-core makes it inherit from EmbeddingStartEvent, so singledispatch routes it via MRO. WorkflowStepOutputEvent / WorkflowRunOutputEvent / SpanCancelledEvent (llama-index-workflows, optional dependency): These events are emitted by the `workflows` package (llama-index-workflows). Handlers are registered inside a try/except ImportError block so the instrumentor continues to work when that package is not installed. WorkflowStepOutputEvent and WorkflowRunOutputEvent carry an `output` string that is recorded as OUTPUT_VALUE on the span. SpanCancelledEvent is silenced with a no-op. https://claude.ai/code/session_01CNFAWAyVyCDpiJif1LVSzX
…Workflow handlers no-ops Two follow-up corrections to the previous commit: 1. SparseEmbeddingStartEvent — add a direct @_process_event.register handler instead of relying on singledispatch MRO resolution. The MRO approach only works when SparseEmbeddingStartEvent inherits from EmbeddingStartEvent (a companion llama-index-core PR), but users installing llama-index-core from PyPI still get the old class that inherits directly from BaseEvent, so the warning persisted. A direct handler sets span_kind = EMBEDDING unconditionally and works with all installed versions of llama-index-core. 2. WorkflowStepOutputEvent / WorkflowRunOutputEvent — change from setting OUTPUT_VALUE to no-ops. The output string is produced by summarize_event(), which truncates field values to 50 chars and the whole string to 200 chars (e.g. "Routing(plan='- [x] Retrieve official Desmo ...')"). The @dispatcher.span instrumentation that closes the span already captures the full, structured return value as OUTPUT_VALUE; our handler was overwriting that richer value with the lossy summary. No-op handlers still suppress the "Unhandled event" warning without degrading the trace data. https://claude.ai/code/session_01CNFAWAyVyCDpiJif1LVSzX
SparseEmbeddingEndEvent and Workflow*Event
SparseEmbeddingEndEvent and Workflow*EventSparseEmbeddingEndEvent and Workflow*OutputEvent
|
I did the follow-up after realizing that I don't really know how LlamaIndex coordinates this type of change with you guys but I would assume that this requires acceptance from maintainers of the LlamaIndex and LlamaIndex Workflows repos? Anyway I tested this in my local setup by referencing all 3 PRs. The warnings are gone and the output looks good to me (the only change is in the SparseEmbeddingOutputEvent attributes). I hope this gets merged since the sheer amount of logged warnings was honestly quite annoying. Cheers |
|
Chiming in from the llamaindex side. Having this change spread across 3 repos seems pretty hard to get right and make properly compatible. Perhaps this default should just be changed to a debug, or have something that more reasonably dumps the event contents as (maybe truncated) json @singledispatchmethod
def _process_event(self, event: BaseEvent) -> None:
logger.warning(f"Unhandled event of type {event.__class__.__qualname__}") |
Fix LlamaIndex and LlamaIndex Workflows Unhandled Event Logs
This PR registers singledispatch handlers for four previously unhandled event types that were producing spurious WARNING logs:
The fix will take effect once the companion fixes in the llama_index and workflows-py repositories are also merged.
llama-index-core ->
SparseEmbeddingEndEventFind the PR here.
Sparse embedding vectors are Dict[int, float] (token-id → weight), incompatible with the EMBEDDING_VECTOR attribute (List[float]).
The handler records the text chunks and skips the vectors, keeping the span populated without violating the semantic convention.
Note: SparseEmbeddingStartEvent no longer needs a handler here because a companion fix in llama-index-core makes it inherit from EmbeddingStartEvent, so singledispatch routes it via MRO.
llama-index-workflows (optional dependency) ->
WorkflowStepOutputEvent/WorkflowRunOutputEvent/SpanCancelledEventFind the PR here.
These events are emitted by the
workflowspackage (llama-index-workflows). Handlers are registered inside a try/except ImportError block so the instrumentor continues to work when that package is not installed.WorkflowStepOutputEvent and WorkflowRunOutputEvent carry an
outputstring that is recorded as OUTPUT_VALUE on the span. SpanCancelledEvent is silenced with a no-op.