fix(captain): normalize captured content after slicing

This commit is contained in:
aakashb95
2026-07-23 11:33:33 +05:30
parent bd98421e57
commit fe573f77b6
@@ -74,11 +74,8 @@ class Captain::Assistant::SessionCaptureService
# (assistant replies, tool calls/results, handoff hops).
def current_turn_history
history = Array(context[:conversation_history])
turn_start_index = context[:captain_v2_turn_start_index]
return history[turn_start_index..] if turn_start_index
last_user_index = history.rindex { |message| message[:role].to_s == 'user' }
current_turn = last_user_index ? history[last_user_index..] : history
turn_start_index = context[:captain_v2_turn_start_index] || history.rindex { |message| message[:role].to_s == 'user' } || 0
current_turn = history[turn_start_index..]
current_turn.map do |message|
content = message[:content]