Describe the bug
OtelTracingMiddleware.onModelCall only records message count and token usage. It does not serialize the actual content of input messages or the model response text into span attributes or events. As a result, OTLP-compatible backends (e.g. Langfuse) show empty input/output for every trace.
To Reproduce
ReActAgent agent = ReActAgent.builder()
.name("assistant")
.model(model)
.middleware(new OtelTracingMiddleware())
.build();
Invoke the agent with any user message. Observe in Langfuse (or any OTLP backend):
- The
chat <model> span shows gen_ai.request.messages.count and token counts.
- Input messages and response content are empty.
Expected behavior
The span should include the full content of input messages and the model response, following the OpenTelemetry GenAI semantic conventions (gen_ai.prompt.* / gen_ai.completion.*, or equivalent span events).
Error messages
No exception. Input/output fields are silently empty.
Root cause
Current onModelCall implementation:
.setAttribute("gen_ai.request.messages.count", (long) input.messages().size())
// message content never written
// doOnNext only handles token counts:
private void setModelResponseAttributes(Span span, ModelCallEndEvent event) {
span.setAttribute("gen_ai.usage.input_tokens", (long) usage.getInputTokens());
span.setAttribute("gen_ai.usage.output_tokens", (long) usage.getOutputTokens());
// response text never written
}
The deprecated TelemetryTracer used getLLMRequestAttributes and getLLMResponseAttributes helpers (in AttributesExtractors) to serialize full message content. OtelTracingMiddleware has no equivalent implementation.
Environment
- AgentScope-Java Version: 2.0.0-RC4
- Java Version: 21
- OS: Windows 11
Additional context
This is a functional regression compared to the deprecated TelemetryTracer. The fix requires serializing input.messages() content into span attributes or events on onModelCall, and extracting the response text from ModelCallEndEvent to write as the output attribute.
Related to #1938 (orphan span issue) — both need to be fixed together for OtelTracingMiddleware to be a viable replacement for TelemetryTracer.
Describe the bug
OtelTracingMiddleware.onModelCallonly records message count and token usage. It does not serialize the actual content of input messages or the model response text into span attributes or events. As a result, OTLP-compatible backends (e.g. Langfuse) show empty input/output for every trace.To Reproduce
Invoke the agent with any user message. Observe in Langfuse (or any OTLP backend):
chat <model>span showsgen_ai.request.messages.countand token counts.Expected behavior
The span should include the full content of input messages and the model response, following the OpenTelemetry GenAI semantic conventions (
gen_ai.prompt.*/gen_ai.completion.*, or equivalent span events).Error messages
No exception. Input/output fields are silently empty.
Root cause
Current
onModelCallimplementation:The deprecated
TelemetryTracerusedgetLLMRequestAttributesandgetLLMResponseAttributeshelpers (inAttributesExtractors) to serialize full message content.OtelTracingMiddlewarehas no equivalent implementation.Environment
Additional context
This is a functional regression compared to the deprecated
TelemetryTracer. The fix requires serializinginput.messages()content into span attributes or events ononModelCall, and extracting the response text fromModelCallEndEventto write as the output attribute.Related to #1938 (orphan span issue) — both need to be fixed together for
OtelTracingMiddlewareto be a viable replacement forTelemetryTracer.