Skip to content

[BUG] Tool result show up as user message in traces #714

@zastrowm

Description

@zastrowm

Discussed in #700

Originally posted by robin-fiddler August 19, 2025
I am ingesting otel traces from strands and noticed a peculiar behaviour. The output of the tool in events is named "gen_ai.user.message". Shouldn't it be "gen_ai.tool.message"

Relevant Span

    {
         "name": "gen_ai.user.message",
         "timestamp": "2025-08-20T03:09:34.216671Z",
          "attributes": {
                "content": "[{\"toolResult\": {\"toolUseId\": \"call_QxbpbXvAbPqd9h6IHDZMoVh8\", \"status\": \"success\", \"content\": [{\"text\": \"Successfully booked a flight from Delhi to Bangalore for 2023-11-17.\"}]}}]"
          }
    }

Full span below

{
    "name": "chat",
    "context": {
        "trace_id": "0x080dba41eb115cdb89a09daecd8fd7ac",
        "span_id": "0xd98434e92977c6f2",
        "trace_state": "[]"
    },
    "kind": "SpanKind.CLIENT",
    "parent_id": "0x4eb3cb67adb41a56",
    "start_time": "2025-08-20T03:09:34.216613Z",
    "end_time": "2025-08-20T03:09:35.383550Z",
    "status": {
        "status_code": "OK"
    },
    "attributes": {
        "gen_ai.event.start_time": "2025-08-20T03:09:34.216614+00:00",
        "gen_ai.system": "strands-agents",
        "gen_ai.operation.name": "chat",
        "gen_ai.request.model": "gpt-4o-mini",
        "gen_ai.event.end_time": "2025-08-20T03:09:35.383478+00:00",
        "gen_ai.usage.prompt_tokens": 330,
        "gen_ai.usage.input_tokens": 330,
        "gen_ai.usage.completion_tokens": 26,
        "gen_ai.usage.output_tokens": 26,
        "gen_ai.usage.total_tokens": 356
    },
    "events": [
        {
            "name": "gen_ai.user.message",
            "timestamp": "2025-08-20T03:09:34.216637Z",
            "attributes": {
                "content": "[{\"text\": \"book a flight from delhi to bangalore tomorrow\"}]"
            }
        },
        {
            "name": "gen_ai.assistant.message",
            "timestamp": "2025-08-20T03:09:34.216655Z",
            "attributes": {
                "content": "[{\"toolUse\": {\"toolUseId\": \"call_QxbpbXvAbPqd9h6IHDZMoVh8\", \"name\": \"book_flight\", \"input\": {\"from_airport\": \"Delhi\", \"to_airport\": \"Bangalore\", \"date\": \"2023-11-17\"}}}]"
            }
        },
        {
            "name": "gen_ai.user.message",
            "timestamp": "2025-08-20T03:09:34.216671Z",
            "attributes": {
                "content": "[{\"toolResult\": {\"toolUseId\": \"call_QxbpbXvAbPqd9h6IHDZMoVh8\", \"status\": \"success\", \"content\": [{\"text\": \"Successfully booked a flight from Delhi to Bangalore for 2023-11-17.\"}]}}]"
            }
        },
        {
            "name": "gen_ai.choice",
            "timestamp": "2025-08-20T03:09:35.383454Z",
            "attributes": {
                "finish_reason": "end_turn",
                "message": "[{\"text\": \"Your flight from Delhi to Bangalore for tomorrow has been successfully booked! If you need any more assistance, feel free to ask.\"}]"
            }
        }
    ],
    "links": [],
    "resource": {
        "attributes": {
            "telemetry.sdk.language": "python",
            "telemetry.sdk.name": "opentelemetry",
            "telemetry.sdk.version": "1.36.0",
            "service.name": "strands-agents",
            "service.version": "1.5.0"
        },
        "schema_url": ""
    }
}
```</div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions