From 0fbb1fbd9274c6434e2aa0476ed4fee3918ada38 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 12 May 2026 16:40:27 -0400 Subject: [PATCH] fix(tools): search_projects returns success:True so result isn't mislabeled error Co-Authored-By: Claude Opus 4.7 (1M context) --- .../services/tools/projects.py | 2 +- tests/test_tool_use_fixes.py | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/test_tool_use_fixes.py diff --git a/src/fabledassistant/services/tools/projects.py b/src/fabledassistant/services/tools/projects.py index 83aefcb..899c317 100644 --- a/src/fabledassistant/services/tools/projects.py +++ b/src/fabledassistant/services/tools/projects.py @@ -158,7 +158,7 @@ async def search_projects_tool(*, user_id, arguments, **_ctx): "summary_snippet": (p.auto_summary or p.description or "")[:200], "score": round(score, 3), }) - return {"type": "projects_list", "data": {"projects": results}} + return {"success": True, "type": "projects_list", "data": {"projects": results}} @tool( diff --git a/tests/test_tool_use_fixes.py b/tests/test_tool_use_fixes.py new file mode 100644 index 0000000..d763a06 --- /dev/null +++ b/tests/test_tool_use_fixes.py @@ -0,0 +1,30 @@ +"""Tests for the tool-use fixes from the 2026-05-08 journal session.""" + +from types import SimpleNamespace +from unittest.mock import AsyncMock, patch + +import pytest + + +def _project(pid: int, title: str, description: str = "", auto_summary: str = ""): + return SimpleNamespace( + id=pid, title=title, description=description, auto_summary=auto_summary, + ) + + +@pytest.mark.asyncio +async def test_search_projects_tool_returns_success_true(): + """The dispatcher sets status from result['success']; without this key + the call gets labeled 'error' even when data is returned.""" + from fabledassistant.services.tools import projects as projects_tool + + fake_projects = [_project(5, "Famous-Supply Work topics", "AT&T fiber circuit")] + + with patch.object(projects_tool, "list_projects", new=AsyncMock(return_value=fake_projects)): + result = await projects_tool.search_projects_tool( + user_id=1, arguments={"query": "famous supply"}, + ) + + assert result["success"] is True + assert result["type"] == "projects_list" + assert len(result["data"]["projects"]) == 1