Refactoring LLM Message Display for Trace Readability #3543
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This enhancement focuses on improving the readability of LLM conversation history within trace and span inputs/outputs.
Previously, the system only extracted and displayed the last message from conversation arrays (like those used by OpenAI and LangChain). This made it difficult to review the full context of multi-turn interactions.
The update to the prettifyMessage utility now extracts all individual messages from recognized array formats. It structures them into a single string using:
A Message Header (---[ ROLE MESSAGE ]---) to identify the message type (e.g., HUMAN, AI, tool_call).
A Message Divider (\n\n ----------------- \n\n) to clearly separate each message.
This structured string is consumed by the front-end rendering components, which interpret the delimiters to render each message as a separate, collapsible section. This allows users to easily navigate and review the complete conversational flow within a single trace or span.