SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
feat(tracedetail): format LangChain serialised runs (#13137)
Nityananda Gohain1dbc9ed47c27
diff --git a/pkg/types/aiobservabilitytypes/message_format.go b/pkg/types/aiobservabilitytypes/message_format.goindex 0bcbe85602..06cf580673 100644--- a/pkg/types/aiobservabilitytypes/message_format.go+++ b/pkg/types/aiobservabilitytypes/message_format.go@@ -14,6 +14,7 @@ import (const (FormatterSemconv = "semconv"FormatterOpenInference = "openinference"+ FormatterLangChain = "langchain"FormatterOpenAIChat = "openai.chat"FormatterOpenAIResponses = "openai.responses"FormatterText = "text"@@ -151,6 +152,8 @@ func (f *formatting) side(value any, role Role) (OutputMessages, string) {}case map[string]any:switch {+ case isLangChainRun(v):+ return f.langChainRun(v), FormatterLangChaincase isResponsesResponse(v):return f.responsesResponse(v), FormatterOpenAIResponsescase isResponsesRequest(v):diff --git a/pkg/types/aiobservabilitytypes/message_format_langchain.go b/pkg/types/aiobservabilitytypes/message_format_langchain.gonew file mode 100644index 0000000000..d0cc7a493f--- /dev/null+++ b/pkg/types/aiobservabilitytypes/message_format_langchain.go@@ -0,0 +1,200 @@+package aiobservabilitytypes++import "github.com/SigNoz/signoz/pkg/valuer"++// Format: LangChain's serialised run inputs and outputs, {messages: [[Serializable]]} and+// {generations: [[{text, generation_info, message}]]}, each message {lc: 1, type: "constructor",+// id: [..., class], kwargs: {content, tool_calls, tool_call_id, name, ...}}:+// https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/core/langchain_core/load/serializable.py#L297+// https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/core/langchain_core/outputs/llm_result.py#L23+// https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/core/langchain_core/messages/ai.py#L170+// Written by: the LangSmith OTel exporter as gen_ai.prompt and gen_ai.completion, which the span mapper+// moves onto gen_ai.input.messages and gen_ai.output.messages:+// https://github.com/langchain-ai/langsmith-sdk/blob/bf325f3a0d9f415096a4632099b7faff355cde53/python/langsmith/_internal/otel/_otel_exporter.py#L761+// https://github.com/langchain-ai/langsmith-sdk/blob/bf325f3a0d9f415096a4632099b7faff355cde53/python/langsmith/_internal/otel/_otel_exporter.py#L843+// The envelope and the message classes are langchain_core's and shared by every partner package; the+// partners differ in the key that carries the finish reason and in the content blocks they keep.+// Handled: string content, langchain_core's standard content blocks and the OpenAI block spellings,+// tool_calls, tool messages, the finish reason of a generation.+// Not yet: the provider-native thinking blocks anthropic, bedrock and google keep in the content, kept+// as sent:+// https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/partners/anthropic/langchain_anthropic/chat_models.py#L866+// https://github.com/langchain-ai/langchain-aws/blob/910b79b9787eee773cde65bdd9e94266d6cf6f6c/libs/aws/langchain_aws/chat_models/bedrock_converse.py#L401+// https://github.com/langchain-ai/langchain-google/blob/9f72e9a344235a488396ac2c62d360ceb2b1c81c/libs/genai/langchain_google_genai/chat_models.py#L165++// LangChain message classes to roles; ChatMessage carries its own role in kwargs.+var langChainRoles = map[string]Role{+ "SystemMessage": RoleSystem, "SystemMessageChunk": RoleSystem,+ "HumanMessage": RoleUser, "HumanMessageChunk": RoleUser,+ "AIMessage": RoleAssistant, "AIMessageChunk": RoleAssistant,+ "ToolMessage": RoleTool, "ToolMessageChunk": RoleTool, "FunctionMessage": RoleTool, "FunctionMessageChunk": RoleTool,+}++// isLangChainRun looks for the generations list or a messages batch of serialised messages.+func isLangChainRun(m map[string]any) bool {+ if _, ok := m["generations"].([]any); ok {+ return true+ }+ batches, ok := m["messages"].([]any)+ if !ok || len(batches) == 0 {+ return false+ }+ first, ok := batches[0].([]any)+ if !ok {+ return false+ }+ msg, ok := firstObject(first)+ return ok && msg["lc"] != nil+}++// langChainRun converts the run inputs, every batch of messages in order, or the run outputs, one+// message per generation.+func (f *formatting) langChainRun(m map[string]any) OutputMessages {+ var out OutputMessages+ if batches, ok := m["messages"].([]any); ok {+ for _, batch := range batches {+ if list, ok := batch.([]any); ok {+ out = append(out, f.langChainMessages(list)...)+ }+ }+ return out+ }+ batches, _ := m["generations"].([]any)+ for _, batch := range batches {+ list, _ := batch.([]any)+ for _, item := range list {+ generation, ok := item.(map[string]any)+ if !ok {+ out = append(out, genericMessage(item))+ continue+ }+ msg := OutputMessage{Role: RoleAssistant, Parts: Parts{}}+ if message, ok := generation["message"].(map[string]any); ok {+ msg = f.langChainMessage(message)+ } else if text := stringOf(generation["text"]); text != "" {+ msg.Parts = Parts{part(textPart(text))}+ }+ if info, ok := generation["generation_info"].(map[string]any); ok && msg.FinishReason == nil {+ msg.FinishReason = finishReason(stringOf(info["finish_reason"]))+ }+ out = append(out, msg)+ }+ }+ return out+}++func (f *formatting) langChainMessages(list []any) OutputMessages {+ out := make(OutputMessages, 0, len(list))+ for _, item := range list {+ m, ok := item.(map[string]any)+ if !ok {+ out = append(out, genericMessage(item))+ continue+ }+ out = append(out, f.langChainMessage(m))+ }+ return out+}++// langChainMessage converts one serialised message. A tool_call or tool_use block in the content repeats+// a call that tool_calls already carries, langchain_core adds the former from the latter and+// langchain-anthropic keeps the provider's block beside it:+// https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/core/langchain_core/messages/ai.py#L274+// https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/partners/anthropic/langchain_anthropic/chat_models.py#L2571+// A failed call leaves the error body in response_metadata.+func (f *formatting) langChainMessage(m map[string]any) OutputMessage {+ kwargs, _ := m["kwargs"].(map[string]any)+ msg := OutputMessage{Role: langChainRole(m, kwargs), Parts: Parts{}, Name: optionalString(kwargs["name"])}+ if id := stringOf(kwargs["tool_call_id"]); msg.Role == RoleTool && id != "" {+ msg.Parts = Parts{part(ToolCallResponsePart{Type: PartTypeToolCallResponse, ID: &id, Response: toolResponse(kwargs["content"])})}+ return msg+ }+ calls, _ := kwargs["tool_calls"].([]any)+ switch content := kwargs["content"].(type) {+ case string:+ if content != "" {+ msg.Parts = append(msg.Parts, part(textPart(content)))+ }+ case []any:+ for _, item := range content {+ if block, ok := item.(map[string]any); ok && len(calls) > 0 && (block["type"] == "tool_call" || block["type"] == "tool_use") {+ continue+ }+ msg.Parts = append(msg.Parts, langChainBlock(item))+ }+ }+ for _, item := range calls {+ if call, ok := item.(map[string]any); ok {+ msg.Parts = append(msg.Parts, part(ToolCallRequestPart{Type: PartTypeToolCall, Name: stringOf(call["name"]), ID: optionalString(call["id"]), Arguments: decode(call["args"])}))+ }+ }+ if metadata, ok := kwargs["response_metadata"].(map[string]any); ok {+ msg.FinishReason = langChainFinishReason(metadata)+ if body, ok := metadata["body"].(map[string]any); ok && body["error"] != nil {+ msg.FinishReason = finishReason("error")+ }+ }+ return msg+}++// langChainFinishReason reads the key each partner writes into response_metadata: finish_reason for+// most, stop_reason for anthropic, stopReason for bedrock, done_reason for ollama:+// https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/partners/anthropic/langchain_anthropic/chat_models.py#L2510+// https://github.com/langchain-ai/langchain-aws/blob/910b79b9787eee773cde65bdd9e94266d6cf6f6c/libs/aws/langchain_aws/chat_models/bedrock_converse.py#L265+// https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/partners/ollama/langchain_ollama/chat_models.py#L24+func langChainFinishReason(metadata map[string]any) *FinishReason {+ for _, key := range []string{"finish_reason", "stop_reason", "stopReason", "done_reason"} {+ if fr := finishReason(stringOf(metadata[key])); fr != nil {+ return fr+ }+ }+ return nil+}++// langChainBlock converts one content block: langchain_core's standard reasoning and media blocks, else+// the OpenAI spellings contentPart knows:+// https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/core/langchain_core/messages/content.py#L456+// https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/core/langchain_core/messages/content.py#L498+func langChainBlock(item any) Part {+ block, ok := item.(map[string]any)+ if !ok {+ return contentPart(item)+ }+ typ := stringOf(block["type"])+ switch typ {+ case "reasoning":+ return part(ReasoningPart{Type: PartTypeReasoning, Content: stringOf(block["reasoning"])})+ case "image", "audio", "video", "file":+ modality := Modality{valuer.NewString(typ)}+ if typ == "file" {+ modality = ModalityDocument+ }+ mime := optionalString(block["mime_type"])+ switch {+ case stringOf(block["url"]) != "":+ return part(mediaPart(stringOf(block["url"]), modality))+ case stringOf(block["base64"]) != "":+ return part(BlobPart{Type: PartTypeBlob, Modality: modality, MimeType: mime, Content: stringOf(block["base64"])})+ case stringOf(block["file_id"]) != "":+ return part(FilePart{Type: PartTypeFile, Modality: modality, MimeType: mime, FileID: stringOf(block["file_id"])})+ }+ }+ return contentPart(item)+}++// langChainRole reads the message class from the serialised id path, falling back to the type+// alias in kwargs:+// https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/core/langchain_core/messages/chat.py#L18+// https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/core/langchain_core/messages/human.py#L29+func langChainRole(m, kwargs map[string]any) Role {+ if id, ok := m["id"].([]any); ok && len(id) > 0 {+ class := stringOf(id[len(id)-1])+ if r, ok := langChainRoles[class]; ok {+ return r+ }+ if class == "ChatMessage" || class == "ChatMessageChunk" {+ return role(stringOf(kwargs["role"]))+ }+ }+ return role(stringOf(kwargs["type"]))+}diff --git a/pkg/types/aiobservabilitytypes/message_format_langchain_test.go b/pkg/types/aiobservabilitytypes/message_format_langchain_test.gonew file mode 100644index 0000000000..b6b3ecca3d--- /dev/null+++ b/pkg/types/aiobservabilitytypes/message_format_langchain_test.go@@ -0,0 +1,77 @@+package aiobservabilitytypes++import "testing"++// Captured cases are gen_ai.input.messages and gen_ai.output.messages as the collector stored them for+// the SigNoz/scripts langsmith capture, the LangSmith OTel exporter's serialised run inputs and outputs;+// the others follow langchain_core and the partner packages at the linked lines.+func TestFormat_LangChain(t *testing.T) {+ runFormatCases(t, []formatCase{+ {+ // langsmith capture, ChatOpenAI span after the tool ran+ name: "SerialisedMessages_RolesFromClasses_ToolCallAndToolMessage",+ input: `{"messages":[[{"lc":1,"type":"constructor","id":["langchain","schema","messages","SystemMessage"],"kwargs":{"content":"You are a weather assistant. Call get_weather once per city.","type":"system"}},{"lc":1,"type":"constructor","id":["langchain","schema","messages","HumanMessage"],"kwargs":{"content":"What's the weather in Bengaluru?","type":"human"}},{"lc":1,"type":"constructor","id":["langchain","schema","messages","AIMessage"],"kwargs":{"content":"","additional_kwargs":{"refusal":null},"response_metadata":{"finish_reason":"tool_calls","logprobs":null},"type":"ai","id":"lc_run--019e844a","tool_calls":[{"name":"get_weather","args":{"city":"Bengaluru"},"id":"call_nbrbkc5fom95q8uMA2bCvH6s","type":"tool_call"}],"invalid_tool_calls":[]}},{"lc":1,"type":"constructor","id":["langchain","schema","messages","ToolMessage"],"kwargs":{"content":"{\"city\": \"Bengaluru\", \"temp_c\": 18, \"summary\": \"Clear\"}","type":"tool","tool_call_id":"call_nbrbkc5fom95q8uMA2bCvH6s","status":"success"}}]]}`,+ output: `{"generations":[[{"text":"The weather in Bengaluru is clear, 18°C.","generation_info":{"finish_reason":"stop","logprobs":null},"type":"ChatGeneration","message":{"lc":1,"type":"constructor","id":["langchain","schema","messages","AIMessage"],"kwargs":{"content":"The weather in Bengaluru is clear, 18°C.","additional_kwargs":{"refusal":null},"response_metadata":{"finish_reason":"stop","model_name":"gpt-4o-mini-2024-07-18"},"type":"ai","tool_calls":[],"invalid_tool_calls":[]}}}]],"llm_output":{"model_name":"gpt-4o-mini-2024-07-18"},"run":null,"type":"LLMResult"}`,+ wantInput: `[+ {"role": "system", "parts": [{"type": "text", "content": "You are a weather assistant. Call get_weather once per city."}]},+ {"role": "user", "parts": [{"type": "text", "content": "What's the weather in Bengaluru?"}]},+ {"role": "assistant", "parts": [{"type": "tool_call", "name": "get_weather", "id": "call_nbrbkc5fom95q8uMA2bCvH6s", "arguments": {"city": "Bengaluru"}}]},+ {"role": "tool", "parts": [{"type": "tool_call_response", "id": "call_nbrbkc5fom95q8uMA2bCvH6s", "response": {"city": "Bengaluru", "temp_c": 18, "summary": "Clear"}}]}+ ]`,+ wantOutput: `[{"role": "assistant", "parts": [{"type": "text", "content": "The weather in Bengaluru is clear, 18°C."}], "finish_reason": "stop"}]`,+ },+ {+ // langsmith capture, ChatOpenAI span answering with a tool call: the generation text is empty and+ // the finish reason sits in generation_info+ // https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/core/langchain_core/outputs/generation.py#L28+ name: "GenerationWithToolCalls_ToolCallPart_FinishFromGenerationInfo",+ output: `{"generations":[[{"text":"","generation_info":{"finish_reason":"tool_calls"},"type":"ChatGeneration","message":{"lc":1,"type":"constructor","id":["langchain","schema","messages","AIMessage"],"kwargs":{"content":"","response_metadata":{},"type":"ai","tool_calls":[{"name":"get_weather","args":{"city":"Bengaluru"},"id":"call_1","type":"tool_call"}]}}}]]}`,+ wantInput: `[]`,+ wantOutput: `[{"role": "assistant", "parts": [{"type": "tool_call", "name": "get_weather", "id": "call_1", "arguments": {"city": "Bengaluru"}}], "finish_reason": "tool_call"}]`,+ },+ {+ // langsmith capture, ChatOpenAI span of a failed call: the error body sits in response_metadata+ name: "GenerationWithErrorBody_EmptyMessage_FinishError",+ output: `{"generations":[[{"text":"","generation_info":null,"type":"ChatGeneration","message":{"lc":1,"type":"constructor","id":["langchain","schema","messages","AIMessage"],"kwargs":{"content":"","response_metadata":{"body":{"error":{"message":"Incorrect API key provided","type":"invalid_request_error","code":"invalid_api_key"},"status":401},"headers":{}},"type":"ai"}}}]]}`,+ wantInput: `[]`,+ wantOutput: `[{"role": "assistant", "parts": [], "finish_reason": "error"}]`,+ },+ {+ // a ChatMessage carries its role in kwargs; an AIMessage from langchain-anthropic keeps the tool_use+ // block in its content beside tool_calls+ // https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/core/langchain_core/messages/chat.py#L18+ // https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/partners/anthropic/langchain_anthropic/chat_models.py#L2571+ name: "ChatMessageRole_ToolUseBlockBesideToolCalls_OneToolCallPart",+ input: `{"messages":[[{"lc":1,"type":"constructor","id":["langchain","schema","messages","ChatMessage"],"kwargs":{"role":"developer","content":[{"type":"text","text":"Be brief."}]}},{"lc":1,"type":"constructor","id":["langchain","schema","messages","AIMessage"],"kwargs":{"content":[{"type":"text","text":"Calling."},{"type":"tool_use","id":"toolu_1","name":"get_weather","input":{"city":"Paris"}}],"tool_calls":[{"name":"get_weather","args":{"city":"Paris"},"id":"toolu_1"}]}}]]}`,+ wantInput: `[+ {"role": "developer", "parts": [{"type": "text", "content": "Be brief."}]},+ {"role": "assistant", "parts": [{"type": "text", "content": "Calling."}, {"type": "tool_call", "name": "get_weather", "id": "toolu_1", "arguments": {"city": "Paris"}}]}+ ]`,+ wantOutput: `[]`,+ },+ {+ // the finish reason under the key each partner writes: anthropic stop_reason, ollama done_reason+ // https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/partners/anthropic/langchain_anthropic/chat_models.py#L2510+ // https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/partners/ollama/langchain_ollama/chat_models.py#L24+ name: "PartnerFinishReasonKeys_StopReasonAndDoneReason",+ output: `{"generations":[[{"text":"Hi.","message":{"lc":1,"type":"constructor","id":["langchain","schema","messages","AIMessage"],"kwargs":{"content":"Hi.","response_metadata":{"stop_reason":"end_turn","model":"claude-sonnet-4-5"}}}}],[{"text":"Hel","message":{"lc":1,"type":"constructor","id":["langchain","schema","messages","AIMessage"],"kwargs":{"content":"Hel","response_metadata":{"model":"llama3","done_reason":"length"}}}}]]}`,+ wantInput: `[]`,+ wantOutput: `[{"role": "assistant", "parts": [{"type": "text", "content": "Hi."}], "finish_reason": "stop"}, {"role": "assistant", "parts": [{"type": "text", "content": "Hel"}], "finish_reason": "length"}]`,+ },+ {+ // langchain_core's standard content blocks, as partners write them under output_version v1+ // https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/core/langchain_core/messages/content.py#L456+ // https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/core/langchain_core/messages/content.py#L498+ // https://github.com/langchain-ai/langchain/blob/84ba23c414eca6bf6f6ebd1394a3006378113540/libs/core/langchain_core/messages/content.py#L721+ name: "StandardContentBlocks_ReasoningAndMediaParts",+ output: `{"generations":[[{"text":"It is a duck.","message":{"lc":1,"type":"constructor","id":["langchain","schema","messages","AIMessage"],"kwargs":{"content":[{"type":"reasoning","reasoning":"Looks like a bird."},{"type":"text","text":"It is a duck."},{"type":"image","base64":"iVBORw0KGgo=","mime_type":"image/png"},{"type":"file","url":"https://example.com/a.pdf","mime_type":"application/pdf"}],"response_metadata":{"finish_reason":"stop","output_version":"v1"}}}}]]}`,+ wantInput: `[]`,+ wantOutput: `[{"role": "assistant", "parts": [+ {"type": "reasoning", "content": "Looks like a bird."},+ {"type": "text", "content": "It is a duck."},+ {"type": "blob", "modality": "image", "mime_type": "image/png", "content": "iVBORw0KGgo="},+ {"type": "uri", "modality": "document", "uri": "https://example.com/a.pdf"}+ ], "finish_reason": "stop"}]`,+ },+ })+}diff --git a/tests/integration/tests/tracedetail/02_thread.py b/tests/integration/tests/tracedetail/02_thread.pyindex 4185b33d8b..bfc36ffece 100644--- a/tests/integration/tests/tracedetail/02_thread.py+++ b/tests/integration/tests/tracedetail/02_thread.py@@ -21,7 +21,7 @@ def test_thread_returns_gen_ai_spans_in_order(seed_attribute_evolution("traces", ATTRIBUTE_JSON_ROLLOUT_TIME)now = datetime.now(tz=UTC).replace(microsecond=0)trace_id = TraceIdGenerator.trace_id()- root_id, first_llm_id, tool_id, agent_id, second_llm_id, legacy_llm_id, third_llm_id, flattened_llm_id, responses_llm_id = (TraceIdGenerator.span_id() for _ in range(9))+ root_id, first_llm_id, tool_id, agent_id, second_llm_id, legacy_llm_id, third_llm_id, flattened_llm_id, responses_llm_id, langchain_llm_id = (TraceIdGenerator.span_id() for _ in range(10))resources = {"service.name": "tracedetail-thread"}first_input = json.dumps([{"role": "user", "parts": [{"type": "text", "content": "weather in Bangalore?"}]}])first_output = json.dumps([{"role": "assistant", "parts": [{"type": "tool_call", "id": "call_1", "name": "get_weather", "arguments": {"city": "Bangalore"}}]}])@@ -95,6 +95,22 @@ def test_thread_returns_gen_ai_spans_in_order(},attribute_write_mode="json_only",),+ Traces(+ timestamp=now + timedelta(seconds=1),+ trace_id=trace_id,+ span_id=langchain_llm_id,+ parent_span_id=root_id,+ name="ChatOpenAI",+ resources=resources,+ attributes={+ "gen_ai.request.model": "gpt-4o",+ "gen_ai.input.messages": json.dumps({"messages": [[{"lc": 1, "type": "constructor", "id": ["langchain", "schema", "messages", "HumanMessage"], "kwargs": {"content": "see you", "type": "human"}}]]}),+ "gen_ai.output.messages": json.dumps(+ {"generations": [[{"text": "See you!", "generation_info": {"finish_reason": "stop"}, "type": "ChatGeneration", "message": {"lc": 1, "type": "constructor", "id": ["langchain", "schema", "messages", "AIMessage"], "kwargs": {"content": "See you!", "type": "ai"}}}]]}+ ),+ },+ attribute_write_mode="json_only",+ ),])@@ -103,10 +119,10 @@ def test_thread_returns_gen_ai_spans_in_order(assert response.status_code == HTTPStatus.OK, response.textthread = response.json()["data"]- assert [span["span_id"] for span in thread["spans"]] == [first_llm_id, tool_id, agent_id, second_llm_id, legacy_llm_id, third_llm_id, flattened_llm_id, responses_llm_id]+ assert [span["span_id"] for span in thread["spans"]] == [first_llm_id, tool_id, agent_id, second_llm_id, legacy_llm_id, third_llm_id, flattened_llm_id, responses_llm_id, langchain_llm_id]assert "nextCursor" not in thread- first, tool, agent, input_only, legacy, output_only, flattened, responses = thread["spans"]+ first, tool, agent, input_only, legacy, output_only, flattened, responses, langchain = thread["spans"]assert agent["attributes"]["gen_ai.agent.name"] == "planner"assert agent["formattedInput"] == []assert agent["formattedOutput"] == []@@ -140,6 +156,8 @@ def test_thread_returns_gen_ai_spans_in_order(assert flattened["formattedOutput"] == [{"role": "assistant", "parts": [{"type": "text", "content": "You're welcome."}], "finish_reason": "stop"}]assert responses["formattedInput"] == [{"role": "system", "parts": [{"type": "text", "content": "Be brief."}]}, {"role": "user", "parts": [{"type": "text", "content": "bye"}]}]assert responses["formattedOutput"] == [{"role": "assistant", "parts": [{"type": "text", "content": "Bye!"}], "finish_reason": "stop"}]+ assert langchain["formattedInput"] == [{"role": "user", "parts": [{"type": "text", "content": "see you"}]}]+ assert langchain["formattedOutput"] == [{"role": "assistant", "parts": [{"type": "text", "content": "See you!"}], "finish_reason": "stop"}]def test_thread_paginates_with_cursors(