Skip semantic duplicate check for bare-title tasks/notes
The semantic similarity check was flagging unrelated short-title tasks as duplicates (e.g. "Lore: Shell 0" matching "Lore: Reinitialization 0" at 91%) because with no body, the embedding is purely title-based and co-domain tasks in the same project share a tight embedding neighborhood. Only run the semantic check when the body is ≥ 80 chars — enough content to make a meaningful comparison. The fuzzy title check already covers exact/near-exact title duplicates. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -825,7 +825,7 @@ async def execute_tool(user_id: int, tool_name: str, arguments: dict) -> dict:
|
||||
item_type = "task" if near.status is not None else "note"
|
||||
return {"success": False, "error": f"A {item_type} with a very similar title '{near.title}' already exists (id: {near.id}, similarity: {ratio:.0%}). Use update_note to modify it instead of creating a duplicate."}
|
||||
|
||||
if not arguments.get("confirmed"):
|
||||
if not arguments.get("confirmed") and len(task_body.strip()) >= 80:
|
||||
from fabledassistant.services.embeddings import semantic_search_notes as _ssn
|
||||
sem_query = f"{task_title}\n{task_body}".strip()
|
||||
sem_hits = await _ssn(user_id, sem_query, limit=3, threshold=0.87)
|
||||
@@ -903,7 +903,7 @@ async def execute_tool(user_id: int, tool_name: str, arguments: dict) -> dict:
|
||||
item_type = "task" if near.status is not None else "note"
|
||||
return {"success": False, "error": f"A {item_type} with a very similar title '{near.title}' already exists (id: {near.id}, similarity: {ratio:.0%}). Use update_note to modify it instead of creating a duplicate."}
|
||||
|
||||
if not arguments.get("confirmed"):
|
||||
if not arguments.get("confirmed") and len(note_body.strip()) >= 80:
|
||||
from fabledassistant.services.embeddings import semantic_search_notes as _ssn
|
||||
sem_query = f"{note_title}\n{note_body}".strip()
|
||||
sem_hits = await _ssn(user_id, sem_query, limit=3, threshold=0.87)
|
||||
|
||||
Reference in New Issue
Block a user