jostlebot Claude Opus 4.5 commited on
Commit
a55ae4d
·
1 Parent(s): 9ec4533

Fix debrief bug: capture conversation before clearing state

Browse files

The conversation transcript and setup parameters were being extracted
AFTER the messages were cleared, resulting in empty debrief context.
Now extracts all needed data before clearing session state.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -257,12 +257,14 @@ else:
257
  col1, col2, col3 = st.columns([1, 2, 1])
258
  with col2:
259
  if st.button("🤔 I'm Ready to Debrief", use_container_width=True):
260
- # Clear previous conversation state
261
- st.session_state.messages = []
262
- st.session_state.in_debrief = True
263
-
264
- # Get the original setup parameters
265
  system_msg = next((msg for msg in st.session_state.messages if msg["role"] == "system"), None)
 
 
 
 
 
 
266
  if system_msg:
267
  # Extract parameters from the system message
268
  content = system_msg["content"]
@@ -276,11 +278,9 @@ else:
276
  tone = "Not specified"
277
  goal = "Not specified"
278
 
279
- # Get conversation transcript
280
- conversation_transcript = "\n".join([
281
- f"{msg['role'].capitalize()}: {msg['content']}"
282
- for msg in st.session_state.messages[1:] # Skip system message
283
- ])
284
 
285
  # Prepare debrief system message
286
  debrief_system_message = f"""You are a therapeutic reflection partner. Your role is to help the user understand how they showed up in a difficult relational roleplay, integrating insights from:
 
257
  col1, col2, col3 = st.columns([1, 2, 1])
258
  with col2:
259
  if st.button("🤔 I'm Ready to Debrief", use_container_width=True):
260
+ # Get the original setup parameters BEFORE clearing messages
 
 
 
 
261
  system_msg = next((msg for msg in st.session_state.messages if msg["role"] == "system"), None)
262
+
263
+ # Get conversation transcript BEFORE clearing messages
264
+ conversation_transcript = "\n".join([
265
+ f"{msg['role'].capitalize()}: {msg['content']}"
266
+ for msg in st.session_state.messages[1:] # Skip system message
267
+ ])
268
  if system_msg:
269
  # Extract parameters from the system message
270
  content = system_msg["content"]
 
278
  tone = "Not specified"
279
  goal = "Not specified"
280
 
281
+ # NOW clear conversation state and enter debrief mode
282
+ st.session_state.messages = []
283
+ st.session_state.in_debrief = True
 
 
284
 
285
  # Prepare debrief system message
286
  debrief_system_message = f"""You are a therapeutic reflection partner. Your role is to help the user understand how they showed up in a difficult relational roleplay, integrating insights from: