Re-imagined and re-written Debug tool. Instead of prompting Claude to perform initial analysis (and hoping it did), the tool now works through the debug process as an 'investigation', encouraging Claud to gather its 'findings' / 'hypothesis', stepping back as needed, collecting files it's gone through and keeping track of files relevant to the issue at hand. This structured investiion is then passed to the other model with far greater insight than the original debug tool ever could.
Improved prompts, guard against overengineering and flag that as an antipattern
This commit is contained in:
@@ -13,7 +13,8 @@ import pytest
|
||||
from tools.analyze import AnalyzeTool
|
||||
from tools.chat import ChatTool
|
||||
from tools.codereview import CodeReviewTool
|
||||
from tools.debug import DebugIssueTool
|
||||
|
||||
# from tools.debug import DebugIssueTool # Commented out - debug tool refactored
|
||||
from tools.precommit import Precommit
|
||||
from tools.thinkdeep import ThinkDeepTool
|
||||
|
||||
@@ -182,33 +183,37 @@ class TestPromptRegression:
|
||||
output = json.loads(result[0].text)
|
||||
assert output["status"] == "success"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_debug_normal_error(self, mock_model_response):
|
||||
"""Test debug tool with normal error description."""
|
||||
tool = DebugIssueTool()
|
||||
# NOTE: Debug tool test has been commented out because the debug tool has been
|
||||
# refactored to use a self-investigation pattern instead of accepting prompt/error_context fields.
|
||||
# The new debug tool requires fields like: step, step_number, total_steps, next_step_required, findings
|
||||
|
||||
with patch.object(tool, "get_model_provider") as mock_get_provider:
|
||||
mock_provider = MagicMock()
|
||||
mock_provider.get_provider_type.return_value = MagicMock(value="google")
|
||||
mock_provider.supports_thinking_mode.return_value = False
|
||||
mock_provider.generate_content.return_value = mock_model_response(
|
||||
"Root cause: The variable is undefined. Fix: Initialize it..."
|
||||
)
|
||||
mock_get_provider.return_value = mock_provider
|
||||
|
||||
result = await tool.execute(
|
||||
{
|
||||
"prompt": "TypeError: Cannot read property 'name' of undefined",
|
||||
"error_context": "at line 42 in user.js\n console.log(user.name)",
|
||||
"runtime_info": "Node.js v16.14.0",
|
||||
}
|
||||
)
|
||||
|
||||
assert len(result) == 1
|
||||
output = json.loads(result[0].text)
|
||||
assert output["status"] == "success"
|
||||
assert "Next Steps:" in output["content"]
|
||||
assert "Root cause" in output["content"]
|
||||
# @pytest.mark.asyncio
|
||||
# async def test_debug_normal_error(self, mock_model_response):
|
||||
# """Test debug tool with normal error description."""
|
||||
# tool = DebugIssueTool()
|
||||
#
|
||||
# with patch.object(tool, "get_model_provider") as mock_get_provider:
|
||||
# mock_provider = MagicMock()
|
||||
# mock_provider.get_provider_type.return_value = MagicMock(value="google")
|
||||
# mock_provider.supports_thinking_mode.return_value = False
|
||||
# mock_provider.generate_content.return_value = mock_model_response(
|
||||
# "Root cause: The variable is undefined. Fix: Initialize it..."
|
||||
# )
|
||||
# mock_get_provider.return_value = mock_provider
|
||||
#
|
||||
# result = await tool.execute(
|
||||
# {
|
||||
# "prompt": "TypeError: Cannot read property 'name' of undefined",
|
||||
# "error_context": "at line 42 in user.js\n console.log(user.name)",
|
||||
# "runtime_info": "Node.js v16.14.0",
|
||||
# }
|
||||
# )
|
||||
#
|
||||
# assert len(result) == 1
|
||||
# output = json.loads(result[0].text)
|
||||
# assert output["status"] == "success"
|
||||
# assert "Next Steps:" in output["content"]
|
||||
# assert "Root cause" in output["content"]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_analyze_normal_question(self, mock_model_response):
|
||||
|
||||
Reference in New Issue
Block a user