Skip to content

@flue/opentelemetry drops tool error messages: empty exception.message and no span status message #460

Description

@scubamaggo

Describe the Bug

When a tool errors, @flue/opentelemetry (1.0.0-beta.3, with @flue/runtime
1.0.0-beta.9) produces an ERROR span that carries no error text anywhere:

  1. exception.message is empty. The runtime's tool-end observation
    (type: 'tool') includes errorInfo: FlueErrorInfo, whose message field
    contains the real error text (populated by classifyError from the thrown
    Error). The tool-end handler ignores it: it builds the exception via
    errorMessage(event.result), and on error event.result is the
    model-facing content array ([{type: 'text', text: ...}]), which
    errorMessage (string / .message object only) cannot unwrap. So
    recordException fires with an empty message while the message sits unused
    in event.errorInfo.message.

  2. The span status has no message. complete() calls
    span.setStatus({ code: SpanStatusCode.ERROR }) without a message.
    Trace UIs that render status.message (e.g. Arize Phoenix's spans-table
    "error" column) show nothing for error spans.

Expected Behavior

For an errored tool span, the exception event's exception.message should
contain errorInfo.message, and ideally the same text should be passed as
the message in setStatus, e.g. in the tool-end handler prefer
event.errorInfo?.message over deriving from event.result.

Steps to Reproduce

  1. Create a basic flue app with the OpenTelemetry instrumentation registered
    (instrument(createOpenTelemetryInstrumentation({ content: { enabled: true, inline: true } })))
    and an InMemorySpanExporter on the tracer provider.
  2. Register a tool whose execute throws:
    throw new Error('bridge timed out after 20s').
  3. Run a conversation turn that calls the tool, then inspect the finished
    execute_tool span: span.status is { code: ERROR } with no message,
    and the recorded exception event has an empty exception.message
    the text "bridge timed out after 20s" appears nowhere on the span, even
    though the tool-end observation's errorInfo.message contains it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fix pendingFixed on a development branch; lands with the next release

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions