mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(backend/copilot): add conversation_turn to Langfuse trace metadata
Add conversation_turn field to trace metadata with the correct turn number based on user message count. This fixes the Langfuse observability issue where SDK's num_turns always showed '1' when using --resume (which creates a new CLI session each turn). Now Langfuse traces will include: - langsmith.metadata.num_turns: '1' (from SDK, represents current CLI session) - metadata.conversation_turn: <actual turn> (from our code, represents conversation history) This gives us accurate turn tracking for multi-turn conversation analysis.
This commit is contained in:
@@ -1075,7 +1075,10 @@ async def stream_chat_completion_sdk(
|
||||
session_id=session_id,
|
||||
trace_name="copilot-sdk",
|
||||
tags=["sdk"],
|
||||
metadata={"resume": str(use_resume)},
|
||||
metadata={
|
||||
"resume": str(use_resume),
|
||||
"conversation_turn": turn,
|
||||
},
|
||||
)
|
||||
_otel_ctx.__enter__()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user