Fix: new_candidate wird nicht mehr durch Duplikat-Ergebnis ueberschrieben
This commit is contained in:
parent
500f96e61f
commit
c04c7a8f62
1 changed files with 13 additions and 7 deletions
|
|
@ -304,7 +304,6 @@ def _tool_memory_suggest(scope, kind, content, memory_type="temporary", expires_
|
|||
import memory_client
|
||||
from datetime import datetime
|
||||
global last_suggest_result
|
||||
last_suggest_result = {"type": None, "candidate_id": None}
|
||||
_log.info("memory_suggest aufgerufen: scope=%s kind=%s type=%s content=%s", scope, kind, memory_type, content[:80])
|
||||
|
||||
if memory_type not in ("temporary", "permanent"):
|
||||
|
|
@ -331,6 +330,8 @@ def _tool_memory_suggest(scope, kind, content, memory_type="temporary", expires_
|
|||
data["expires_at"] = exp_epoch
|
||||
|
||||
result = memory_client._post("/memory", data)
|
||||
prev_type = last_suggest_result.get("type")
|
||||
|
||||
if result and result.get("duplicate"):
|
||||
ex_status = result.get("existing_status", "?")
|
||||
ex_type = result.get("existing_memory_type", "")
|
||||
|
|
@ -338,22 +339,27 @@ def _tool_memory_suggest(scope, kind, content, memory_type="temporary", expires_
|
|||
ex_id = result.get("existing_id")
|
||||
|
||||
if ex_status == "candidate":
|
||||
last_suggest_result = {"type": "existing_candidate", "candidate_id": ex_id}
|
||||
_log.info("Duplikat: bestehender Kandidat ID=%s", ex_id)
|
||||
if prev_type != "new_candidate":
|
||||
last_suggest_result = {"type": "existing_candidate", "candidate_id": ex_id}
|
||||
_log.info("Duplikat: bestehender Kandidat ID=%s (prev=%s)", ex_id, prev_type)
|
||||
return "Noch nicht bestaetigt — zeige Auswahl erneut."
|
||||
elif ex_status == "active":
|
||||
if ex_type == "temporary" and ex_exp:
|
||||
exp_str = datetime.fromtimestamp(ex_exp).strftime("%d.%m.%Y")
|
||||
last_suggest_result = {"type": "active_temporary", "candidate_id": None}
|
||||
if prev_type != "new_candidate":
|
||||
last_suggest_result = {"type": "active_temporary", "candidate_id": None}
|
||||
return f"Schon temporaer gespeichert bis {exp_str}."
|
||||
elif ex_type == "permanent":
|
||||
last_suggest_result = {"type": "active_permanent", "candidate_id": None}
|
||||
if prev_type != "new_candidate":
|
||||
last_suggest_result = {"type": "active_permanent", "candidate_id": None}
|
||||
return "Schon dauerhaft gespeichert."
|
||||
else:
|
||||
last_suggest_result = {"type": "active_other", "candidate_id": None}
|
||||
if prev_type != "new_candidate":
|
||||
last_suggest_result = {"type": "active_other", "candidate_id": None}
|
||||
return "Bereits aktiv gespeichert."
|
||||
elif ex_status == "archived":
|
||||
last_suggest_result = {"type": "existing_candidate", "candidate_id": ex_id}
|
||||
if prev_type != "new_candidate":
|
||||
last_suggest_result = {"type": "existing_candidate", "candidate_id": ex_id}
|
||||
memory_client._patch(f"/memory/{ex_id}", {"status": "candidate"})
|
||||
return "War archiviert — erneut als Kandidat vorgeschlagen."
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue