async def test_conversation_history_included_with_continuation_id(self, mock_add_turn):
        """Test that conversation history (including file context) is included when using continuation_id"""

        # Create a thread context with previous turns including files
        _thread_context = ThreadContext(
            thread_id="test-history-id",
            created_at="2023-01-01T00:00:00Z",
            last_updated_at="2023-01-01T00:02:00Z",
            tool_name="analyze",  # Started with analyze tool
            turns=[
                ConversationTurn(
                    role="assistant",
                    content="I've analyzed the authentication module and found several security issues.",
                    timestamp="2023-01-01T00:01:00Z",
                    tool_name="analyze",
                    files=["/src/auth.py", "/src/security.py"],  # Files from analyze tool
                ),
                ConversationTurn(
                    role="assistant",
                    content="The code review shows these files have critical vulnerabilities.",
                    timestamp="2023-01-01T00:02:00Z",
                    tool_name="codereview",
                    files=["/src/auth.py", "/tests/test_auth.py"],  # Files from codereview tool
                ),
            ],
            initial_context={"question": "Analyze authentication security"},
        )

        # Mock add_turn to return success
        mock_add_turn.return_value = True

        # Mock the model to capture what prompt it receives
        captured_prompt = None

        with patch.object(self.tool, "create_model") as mock_create_model:
            mock_model = Mock()
            mock_response = Mock()
            mock_response.candidates = [
                Mock(
                    content=Mock(parts=[Mock(text="Response with conversation context")]),
                    finish_reason="STOP",
                )
            ]

            def capture_prompt(prompt):
                nonlocal captured_prompt
                captured_prompt = prompt
                return mock_response

            mock_model.generate_content.side_effect = capture_prompt
            mock_create_model.return_value = mock_model

            # Execute tool with continuation_id
            # In the corrected flow, server.py:reconstruct_thread_context
            # would have already added conversation history to the prompt
            # This test simulates that the prompt already contains conversation history
            arguments = {
                "prompt": "What should we fix first?",
                "continuation_id": "test-history-id",
                "files": ["/src/utils.py"],  # New file for this turn
            }
            response = await self.tool.execute(arguments)

            # Verify response succeeded
            response_data = json.loads(response[0].text)
            assert response_data["status"] == "success"

            # Note: After fixing the duplication bug, conversation history reconstruction
            # now happens ONLY in server.py, not in tools/base.py
            # This test verifies that tools/base.py no longer duplicates conversation history

            # Verify the prompt is captured
            assert captured_prompt is not None

            # The prompt should NOT contain conversation history (since we removed the duplicate code)
            # In the real flow, server.py would add conversation history before calling tool.execute()
            assert "=== CONVERSATION HISTORY ===" not in captured_prompt

            # The prompt should contain the current request
            assert "What should we fix first?" in captured_prompt
            assert "Files in current request: /src/utils.py" in captured_prompt

            # This test confirms the duplication bug is fixed - tools/base.py no longer
            # redundantly adds conversation history that server.py already added
Test that conversation history (including file context) is included when using continuation_id
tests/test_conversation_history_bug.py