Gives a kind-less root AI span a fallback openinference.span.kind so it survives an
OpenInference span filter and serves as the exported trace root.
Some framework "wrapper" spans (e.g. a per-turn span an agent framework emits on top of
the Vercel AI SDK) carry an ai.* operation name the kind map doesn't recognize, so
attribute conversion leaves them without a span kind — which means a filter would drop
them even after reparentOrphanedSpan makes them a root, re-orphaning their AI
children. This tags such a span AGENT so it is recognized and kept.
AGENT is the right default precisely because only AI-like roots are ever promoted:
non-AI spans are filtered out, never promoted, so a promoted span is the top-level AI
wrapper of its trace. This stays name-agnostic — it keys off span shape (a root, AI-like
span the kind map left without a kind), not any framework name. A framework that wants a
different kind for its own wrapper can set it before this runs (this only fires when the
kind is still unset).
Recognized spans (the kind map assigned a kind) and nested spans are untouched. Runs at
onEnd, after attribute conversion and before the export filter.
Gives a kind-less root AI span a fallback
openinference.span.kindso it survives an OpenInference span filter and serves as the exported trace root.Some framework "wrapper" spans (e.g. a per-turn span an agent framework emits on top of the Vercel AI SDK) carry an
ai.*operation name the kind map doesn't recognize, so attribute conversion leaves them without a span kind — which means a filter would drop them even after reparentOrphanedSpan makes them a root, re-orphaning their AI children. This tags such a spanAGENTso it is recognized and kept.AGENTis the right default precisely because only AI-like roots are ever promoted: non-AI spans are filtered out, never promoted, so a promoted span is the top-level AI wrapper of its trace. This stays name-agnostic — it keys off span shape (a root, AI-like span the kind map left without a kind), not any framework name. A framework that wants a different kind for its own wrapper can set it before this runs (this only fires when the kind is still unset).Recognized spans (the kind map assigned a kind) and nested spans are untouched. Runs at onEnd, after attribute conversion and before the export filter.