David-stout commited on
Commit
7aada6b
·
verified ·
1 Parent(s): 8e9fa5b

Fix history filter dropping every message: model never saw user input

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -695,7 +695,11 @@ def _history_for_model(history: list) -> list[dict]:
695
  conversation = [{"role": "system", "content": SYSTEM_PROMPT}]
696
  for msg in history or []:
697
  role = msg.get("role", "user")
698
- if role == "system" or msg.get("metadata"):
 
 
 
 
699
  continue
700
  content = msg.get("content", "")
701
  if isinstance(content, list):
 
695
  conversation = [{"role": "system", "content": SYSTEM_PROMPT}]
696
  for msg in history or []:
697
  role = msg.get("role", "user")
698
+ meta = msg.get("metadata") or {}
699
+ # Only skip thought/tool bubbles; Gradio attaches an empty metadata
700
+ # dict to ordinary messages, so a bare truthiness check drops them all.
701
+ is_thought = isinstance(meta, dict) and bool(meta.get("title"))
702
+ if role == "system" or is_thought:
703
  continue
704
  content = msg.get("content", "")
705
  if isinstance(content, list):