fix: preserve Chatwoot message visibility and identity
This commit is contained in:
@@ -191,6 +191,18 @@ def create_task_from_action_result(
|
||||
action_code = data.get("action_code") or "REVIEW_MANUALLY"
|
||||
if str(action_code or "").strip().upper() == "IGNORE_BOUNCE":
|
||||
return None
|
||||
if raw_event_id:
|
||||
# A retry may re-run classification after the action_run was already
|
||||
# persisted. Raw event identity wins over a potentially different LLM
|
||||
# answer and prevents a second work item for the same inbound fact.
|
||||
with engine.begin() as conn:
|
||||
existing = conn.execute(text("""
|
||||
SELECT id::text FROM tasks
|
||||
WHERE raw_event_id=CAST(:raw_event_id AS UUID)
|
||||
ORDER BY created_at LIMIT 1
|
||||
"""), {"raw_event_id": raw_event_id}).first()
|
||||
if existing:
|
||||
return str(existing[0])
|
||||
config = get_action_config(action_code)
|
||||
|
||||
route = data.get("route") or config["route"]
|
||||
|
||||
Reference in New Issue
Block a user