Problem
The LangChain callback currently emits standalone message events for every system/user message seen in on_chat_model_start.
This creates duplicate telemetry because the same prompt messages are already stored inside the corresponding llm event input under input.messages.
In a tool-using interaction, this becomes especially noisy:
system_message
user_message
user_message
user_message
user_message
llm assistant_response
retrieval
tool
system_message
user_message
user_message
user_message
user_message
llm assistant_response
Conceptually, those repeated system/user messages are not new events in the interaction. They are the prompt frame for each model call.
This makes SessionBat's interaction view harder to understand and stores redundant data.
Proposed Change
Change the LangChain callback so it does not auto-emit standalone prompt message events from on_chat_model_start by default.
Instead, the default LangChain telemetry should record:
- one
llm event per model call, including input.messages
- one
tool event per tool call
- one
retrieval event per retriever call
- no separate
message events derived from chat model prompt input
Manual message APIs should continue to work:
interaction.user_message("...")
interaction.message(role="user", content="...")
Those are explicit app-level observations and should not be affected.
Suggested API
Add an opt-in flag for users who still want prompt messages emitted as standalone events:
handler = client.langchain_callback(record_prompt_messages=True)
Default:
record_prompt_messages=False
Implementation Notes
Current duplication appears to come from on_chat_model_start calling _record_messages_from_chat_input(...).
Desired behavior:
- keep storing full prompt messages in the
llm event request/input
- skip
_record_messages_from_chat_input(...) unless record_prompt_messages=True
- update tests that currently expect auto-created
system_message / user_message events from LangChain chat model input
Why Not Remove Retrieval Or Tool Events?
Do not remove either retrieval or tool events for now.
Even when they look duplicated in the UI, they represent different diagnostic layers:
retrieval: documents returned from the retriever/vector/index layer
tool: the tool result returned back to the model
The SessionBat app should group those into one visual execution step when appropriate, but the SDK should preserve both raw observations.
Acceptance Criteria
- LangChain chat model invocations no longer create standalone
message events by default.
- The corresponding
llm event still includes input.messages.
record_prompt_messages=True restores the current standalone message-event behavior.
- Manual
interaction.user_message(...) and interaction.message(...) APIs are unchanged.
- Tool and retriever event behavior is unchanged.
Problem
The LangChain callback currently emits standalone
messageevents for every system/user message seen inon_chat_model_start.This creates duplicate telemetry because the same prompt messages are already stored inside the corresponding
llmevent input underinput.messages.In a tool-using interaction, this becomes especially noisy:
Conceptually, those repeated system/user messages are not new events in the interaction. They are the prompt frame for each model call.
This makes SessionBat's interaction view harder to understand and stores redundant data.
Proposed Change
Change the LangChain callback so it does not auto-emit standalone prompt
messageevents fromon_chat_model_startby default.Instead, the default LangChain telemetry should record:
llmevent per model call, includinginput.messagestoolevent per tool callretrievalevent per retriever callmessageevents derived from chat model prompt inputManual message APIs should continue to work:
Those are explicit app-level observations and should not be affected.
Suggested API
Add an opt-in flag for users who still want prompt messages emitted as standalone events:
Default:
Implementation Notes
Current duplication appears to come from
on_chat_model_startcalling_record_messages_from_chat_input(...).Desired behavior:
llmevent request/input_record_messages_from_chat_input(...)unlessrecord_prompt_messages=Truesystem_message/user_messageevents from LangChain chat model inputWhy Not Remove Retrieval Or Tool Events?
Do not remove either
retrievalortoolevents for now.Even when they look duplicated in the UI, they represent different diagnostic layers:
retrieval: documents returned from the retriever/vector/index layertool: the tool result returned back to the modelThe SessionBat app should group those into one visual execution step when appropriate, but the SDK should preserve both raw observations.
Acceptance Criteria
messageevents by default.llmevent still includesinput.messages.record_prompt_messages=Truerestores the current standalone message-event behavior.interaction.user_message(...)andinteraction.message(...)APIs are unchanged.