Skip to content

fix(llama-index): Suppress unhandled event warnings for SparseEmbeddingEndEvent and Workflow*OutputEvent#2908

Open
enrico-stauss wants to merge 2 commits intoArize-ai:mainfrom
enrico-stauss:claude/rebase-fixes-main-AcATY
Open

fix(llama-index): Suppress unhandled event warnings for SparseEmbeddingEndEvent and Workflow*OutputEvent#2908
enrico-stauss wants to merge 2 commits intoArize-ai:mainfrom
enrico-stauss:claude/rebase-fixes-main-AcATY

Conversation

@enrico-stauss
Copy link
Copy Markdown

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:

  • 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)

The fix will take effect once the companion fixes in the llama_index and workflows-py repositories are also merged.

llama-index-core -> SparseEmbeddingEndEvent

Find 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/SpanCancelledEvent

Find the PR here.
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.

…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
@enrico-stauss enrico-stauss changed the title fix(llama-index): handle SparseEmbeddingEndEvent and Workflow output events fix(llama-index): WIP handle SparseEmbeddingEndEvent and Workflow output events Mar 24, 2026
@enrico-stauss enrico-stauss changed the title fix(llama-index): WIP handle SparseEmbeddingEndEvent and Workflow output events fix(llama-index): Suppress unhandled event warnings for SparseEmbeddingEndEvent and Workflow*Event Mar 24, 2026
@enrico-stauss enrico-stauss changed the title fix(llama-index): Suppress unhandled event warnings for SparseEmbeddingEndEvent and Workflow*Event fix(llama-index): Suppress unhandled event warnings for SparseEmbeddingEndEvent and Workflow*OutputEvent Mar 24, 2026
@enrico-stauss
Copy link
Copy Markdown
Author

I did the follow-up after realizing that self[OUTPUT_VALUE] = event.output serializes pydantic models to just the first characters produced by the __str__ method which is not very informative.

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
Enrico

@adrianlyjak
Copy link
Copy Markdown

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__}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants