···212212 continue
213213 try:
214214 ex = json.loads(line)
215215+ ex = _normalize_exchange(ex)
215216 if facet and ex.get("facet") != facet:
216217 continue
217218 exchanges.append(ex)
···250251 continue
251252 try:
252253 ex = json.loads(line)
254254+ ex = _normalize_exchange(ex)
253255 ts = ex.get("ts", 0)
254256 ex_day = datetime.fromtimestamp(ts / 1000).strftime("%Y%m%d")
255257 if ex_day != today:
···379381 replacement = "No conversation history yet."
380382381383 return re.sub(pattern, replacement, user_instruction, flags=re.DOTALL)
384384+385385+386386+def _normalize_exchange(ex: dict) -> dict:
387387+ """Normalize legacy exchange dicts to the talent namespace."""
388388+ if "talent" not in ex and "muse" in ex:
389389+ ex["talent"] = ex["muse"]
390390+ # Optionally, remove the old 'muse' key if it's no longer needed in the normalized dict
391391+ # del ex["muse"]
392392+ return ex
393393+